• 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

Laravel Sanctum CSRF not authenticating

Saving Data from form to database using AngularJS and php

PHP Warning: Module already loaded in Unknown on line 0

WHERE IN array binding in DB::raw laravel 5.4

phpseclib 2.0 can not use Composer to create autoload

How to unlink image from folder?

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

Object of class stdClass could not be converted to string error

Attempted to call an undefined method named "get" of class "MailController"

Exception thrown during the rendering of a template("Parameter "id" for route "url" must match "[^/]++" ("" given) to generate a corresponding URL.")

storagelogs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied

Unable to Edit config.inc.php

Array to string conversion

Is there an equivalent of DynamoDB on Azure as a PHP session Handler

I need to link Google Sheet with my Laravel

About Contact Privacy policy Terms and conditions