• 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

How to get AJAX to post on second page?

Insert And Retrieve Data in MySQL with $.post Noob Question

php script to delete files older than 24 hrs, deletes all files

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

set mail driver dynamically from database for different email in notification

Laravel phpunit test failing authorization

PHP how to detect if running on arm64 cpu?

What is my SQL missing?

carbon generated datetime not stored correctly into the database

Unable to run composer install

PHPUNIT Test - Expected Status 200 But Received 500

How can I pass the list to the component variable in Laravel?

Detect if PHP session exists

php file upload scanning using clamav, permissions on /tmp/

WordPress Subquery returns more than 1 row on SELECT

About Contact Privacy policy Terms and conditions