• 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

Can we define variables in `.tpl` files?

merging two arrays with specified index

Merge key and value of array index [duplicate]

Utf8 encoding issue with Laravel

Laravel query builder binding parameters more than once

How to make autocomplete work in foreach php loop? (vscode, intellisense)

How to set time with DateTime modify?

Laravel UUID generation

Laravel/docker-compose/redis - Class 'Redis' not found

Laravel after login Two factor not working

Getting output of MS stored procedure on php call

best way to store error messages in Laravel (session or variable)

Laravel phpunit test failing authorization

Problem with fetching data from database in Laravel

What will the best solution for this multiple optional filter?

About Contact Privacy policy Terms and conditions