• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Laravel 5 controller sending JSON integer as string

phpjsonlaravellaravel-5php-5.6


PHP Snippet 1:

return response()->json(["foo" => "bar"], 200, [], JSON_NUMERIC_CHECK);

PHP Snippet 2:

return (int)Post::find(1)->id;

PHP Snippet 3:

class Controller extends BaseController {
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    public static function json($json) {
        return response()->json($json, 200, [], JSON_NUMERIC_CHECK);
    }

PHP Snippet 4:

return self::json($all);

Related Snippets

Set quantity minimum, maximum and step at product level in Woocommerce

Laravel 8: Array to string conversion while calling route:list

oauth-private.key does not exist or is not readable

PHP7 CLI attempts to load xdebug twice - "Cannot load Xdebug - it was already loaded"

PHP error: "The zip extension and unzip command are both missing, skipping."

run a query using EXECUTE BLOCK to prepair a column for an unique-Index

Laravel 5.1 Unknown database type enum requested

Symfony - "framework.test" config is not set to true

Laravel views are showing from cache on one server but works fine on other server

How to run a shell as root from php (apache)

Laravel + phpunit + github actions = Failed asserting that '1' is identical to 1

Laravel Nova, route not found

Codeigniter, Severity: error --> Exception: Too few arguments to function, admin dashboard shows HTTP error 500

XAMPP keeps showing Dashboard/Welcome Page instead of the Configuration Page

how to upload binary image to sql server using php laravel

About Contact Privacy policy Terms and conditions