• 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

correct PHP headers for pdf file download

Can't remotely connect to MySQL error (13) with PHP script, connecting through CLI works

Using spatie/media-library, how to rename a collection of uploaded files?

If action is on a different page do I use fwrite function

Too few arguments to function PendingResourceRegistration::name(),1 passed in C:xampphtdocsproject outesweb.php on line 18 and exactly 2 expected

Symfony run hint kernel.secret parameter not found

How to change HTML structure inside WP <head>

RabbitMQ PRECONDITION_FAILED - unknown delivery tag

Facebook PHP SDK - will not logout properly

"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP

PHP -> Next nearest date defined by array of days in week

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

SlimExceptionHttpNotFoundException

Auto increment id JSON

PHP header location absolute URL

About Contact Privacy policy Terms and conditions