• 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

Creating Combinations of Elements

file_put_content...fail to open stream:Permission denied in Laravel 5

How to disable widget block editor of WordPress?

Two buttons one form

Must be of the type array, null given,

How can I make this nested location configuration use the correct path to call a php program?

Converting array to string and then back in PHP

How to Mock the Request Class in Laravel?

How to install LDAP in Docker php-fpm alpine

json_encode turns array into an object

how to fix Service provider class not found when using repository?

How to test a php login connected to a mysql db through xampp?

SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'column_name' in Laravel

Unit (real unit test) of test laravel relationship

backup files to google drive using PHP

About Contact Privacy policy Terms and conditions