• 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

Why rand() every time I refresh the page?

Script @php artisan package:discover handling the post-autoload-dump event returned with error code 255

Adding the custom page with add_menu_page function on Wordpress

How to disable widget block editor of WordPress?

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

Get Header Authorization value of a login api (sent with username and password in json body) using php curl

How to identify whether webp image is static or animated?

How can I solve "laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system"?

Select option menu read from database and use it's values

Artisan, creating tables in database

Call authenticate manually in router middleware

Laravel get user data with profile

How to use a PHP MVC Controller, one thats invoked by calling a URL, to call and execute more than one function? [duplicate]

CSV to PHP class properties

Symfony redirect if already loggedin from login page

About Contact Privacy policy Terms and conditions