• 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

get data-value with variable value

How to set a domain name with php artisan serve

Laravel - Browser displays message again when I press back button

Maatwebsite Excel 3.1 : how do I skip duplicate data when imported?

PHP Startup Unable to load dynamic library /usr/lib/php/20151012/php_mysqli.dll

Laravel/ PHP: Order By Alphabetical with numbers in order [duplicate]

Cut an arabic string

html-php form submission after validation through JavaScript [closed]

How to fix " Uncaught TypeError: Argument 1 passed to JpGraphException::defaultHandler() " problem in php 7.1.3 and jpgraph 4.2.6?

PHP: Calling MySQL Stored Procedure with Both INPUT AND OUTPUT Parameters (NOT "INOUT")

php curl requesting twice

How to change product Image when variables are selected in Shop and Archive Pages?

How To Access A Column In M-M Relationship Table In Laravel

Laravel query builder binding parameters more than once

The "client_reference_id" argument is not passed

About Contact Privacy policy Terms and conditions