• 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

The sum of the user's points

Magento Installation SQLSTATE[HY000] [2002] No such file or directory error

generate an Excel file using PHP

VichUploaderBundle error "Expected argument of type "File", "NULL" given" when submitting the form without selecting any file

SMTP "Error: DATA not accepted from server!" Opencart 2.3 on InMotionHosting

LARAVEL: How to fetch id dynamically in a query builder?

Laravel - How to properly generate unique slugs from article titles?

How to test laravel controller method?

Declaration of OMDb::query(string $statement) must be compatible with PDO::query

Prestashop cUrl Login

Laravel 5 issue with wherePivot

Laravel 5 issue with wherePivot

Can't call javascript alert alertify library from PHP

Symfony/Form add attribute based on the data

How to show a popup modal in codeIgniter?

About Contact Privacy policy Terms and conditions