• 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

Json_Encode not returning html even i try to encode JSON_HEX_QUOT | JSON_HEX_TAG

Laravel lang slug in url

storagelogs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied

image source not readable

how to upload binary image to sql server using php laravel

Laravel csrf token mismatch for ajax POST Request

Laravel 5.5 change unauthenticated login redirect url

XDebug not working in VScode for php debugging

PHP mail function is sending blank message body

PHP web3 ERC20 token function call

Laravel - How to properly generate unique slugs from article titles?

Laravel 5.2: Unable to locate factory with name [default]

Why isn't my PHP exception working?

Clients authentication and user authentication with laravel

Laravel Unresolvable dependency resolving [Parameter #0 [ <required> $method ]] in class GuzzleHttpPsr7Request

About Contact Privacy policy Terms and conditions