• 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 5.6 bulk inserting json data

Xdebug in Laravel is not working with VSCode

laravel controller function parameters

Losing session data after POST from third party website

500 Internal Server Error on Ajax request. Not sure the origin of the problem

Check if user online laravel

Whats the point of running Laravel with the command 'php artisan serve'?

Multiple order by in WooCommerce

Convert date and time to Jalali in Laravel

how can I set a session variable in Drupal 8 and get it in a php script?

Yii2: How to download backup files using spanjeta/yii2-backup?

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

Laravel lang slug in url

How do I Post to .txt document before form submits

How to run a shell as root from php (apache)

About Contact Privacy policy Terms and conditions