• 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

Minimum order amount except for specific shipping method in WooCommerce

How to use $this->session->set_userdata in codeigniter

Required field only if another field has a value, must be empty otherwise

How can I easily switch between PHP versions on Mac OSX?

Refresh specific HTML content that retrieves data from MySQL

How to get result of the formula on import xlsx with maatwebsite using Laravel? I get formula and not value of the formula

Correct way to use LIKE '%{$var}%' with prepared statements?

Laravel implode array items to new lines

How to render html from a @foreach loop in a textarea

How to Install Composer Require doctrine/dbal

Display the WooCommerce product price inside a custom function

RuntimeException: Unable to create the cache directory (/var/www/sonata/app/cache/dev)

PHP Print to Network Printer

Losing session data after POST from third party website

Why do I have invalid argument supply for foreach in Laravel for json response? [duplicate]

About Contact Privacy policy Terms and conditions