• 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

php script to delete files older than 24 hrs, deletes all files

Add Metadata, headers (Expires, CacheControl) to a file uploaded to Amazon S3 using the Laravel 5.0 Storage facade

Json_Encode not returning html even i try to encode JSON_HEX_QUOT | JSON_HEX_TAG

How can I get user id from session in javascript?

Override default Auth routes in Laravel 7

How do I remove this delivery notification from here?

How to install PHP composer inside a docker container

Laravel eloquent update record without loading from database

How to disable only_full_group_by option in Laravel

Auto increment id JSON

PHP Get value from JSON [duplicate]

How to validate tin and cst using PHP?

strpos(): Argument #1 ($haystack) must be of type string, array given

Clear javascript source cache laravel 5.8

Laravel 8 factory state afterCreating

About Contact Privacy policy Terms and conditions