• 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

How to change the app environment at run time?

How to assert parameter attribute sub-structures in PHPUnit mock call expectations

Laravel Factory not calling callback 'afterCreating'

Laravel lang slug in url

Webscraping Symfony/Panther: Can't get HTML

Symfony - EasyAdmin - Add and remove functions are ignored from AssociationField

Sagepay Error The Vendor failed to provide a RedirectionURL

Laravel relationship belongsToMany with composite primary keys

Laravel php artisan serve to mimic HTTPS

Warning: Unknown: Failed to write session data using user defined save handler. (session.save_path: ) in Unknown on line 0

WHERE IN array binding in DB::raw laravel 5.4

Transpose and flatten multiple rows of array data [duplicate]

Accessors (Getter) & Mutators (Setter) On a Pivot Table in Laravel

Get image type from base64 encoded src string

How to redirect to another page and call a Function there on Angular ng-click

About Contact Privacy policy Terms and conditions