• 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

Unable to Edit config.inc.php

How to fix Call to undefined method AppModelsTableName::factory?

Laravel 5.1 xmlHttpRequest AJAX POST TokenMismatchException

How to submit the custom form data in database in WordPress without plugin using ajax?

Facebook API, get page post link (PHP)

Read users and passwords from a txt file

How to access a var with "-" in PHP [duplicate]

Smarty: undefined extension class 'Smarty_Internal_Method_Get_Template_Vars'

Laravel query builder binding parameters more than once

How to get values inside <![CDATA[values]] > using php DOM?

PHP: convert all UTF-8 characters to HTML entities

Laravel Jetsream Profile page not loading on fresh install

Hi, I am making a contact form thingy, and my php isn't working any reason why?

backup files to google drive using PHP

IlluminateDatabaseQueryException could not find driver [duplicate]

About Contact Privacy policy Terms and conditions