• 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

Symfony process run throws exception - executing on command line works

Laravel Mix Uncaught ReferenceError: $ is not defined

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

PHP random string generator

I want a way to give path to my files which are outside of public folder in laravel

How to reset Laravel AuthManager/guards in between API calls in tests?

How to access a var with "-" in PHP [duplicate]

RabbitMQ PRECONDITION_FAILED - unknown delivery tag

NGINX: connect() to unix:/var/run/php7.2-fpm.sock failed (2: No such file or directory)

Combine multiple columns into an array as one of the key in a results set

Parsing JSON File to array in PHP

Laravel 5: Is there a non-case sensitive way to sort a collection by an attribute?

Currently Using CodeIgniter Framework i have an Error

how can I set a session variable in Drupal 8 and get it in a php script?

Attempt to read property "view" on null when sending password reset email

About Contact Privacy policy Terms and conditions