• 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

PHPUnit gives error: Target [IlluminateContractsViewFactory] is not instantiable

nginx err_connection_refused, can anyone help me?

Adding one microsecond to Datetime object in PHP

How to send parameters in soap request in php in __soapcall() function

get attribute from class not working php 7

Create a new line whenever an array value reaches more than 10 characters

Laravel PHP: multiple project run at the same time [closed]

WHERE IN array binding in DB::raw laravel 5.4

Problem with fetching data from database in Laravel

Issue saving card for customer

target [LaravelFortifyContractsRegisterViewResponse] is not instantiable

What is PHP's equivalent of JavaScript's "array.every()"?

Laravel Displaying image from database

Laravel Pagination links() not working

Why do I have invalid argument supply for foreach in Laravel for json response? [duplicate]

About Contact Privacy policy Terms and conditions