• 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

Array to string conversion

Return multiple values from a function using mysqli_fetch_assoc [closed]

Unable to create lockable file - Laravel 8 & PHP 8

(Laravel) How to delete multiple models including optional relationships?

Creating Combinations of Elements

Error Class "LaravelFortifyFeatures" not found

500 (Internal Server Error) with Laravel & Docker [duplicate]

Popup Window and PHP form

Laravel-fopen: failed to open stream: Permission denied

PHP my timezone is no setting up in PHP.ini File in xampp

How to identify whether webp image is static or animated?

Error converting docx to pdf using Unoconv

How do I pass the dynamic output of a php variable or php function to a CSS variable?

Get Header Authorization value of a login api (sent with username and password in json body) using php curl

Session timeout in Yii2

About Contact Privacy policy Terms and conditions