• 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

Fatal error: [] operator not supported for strings

Clients authentication and user authentication with laravel

How to convert time from one timezone to another in PHP

Laravel Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) on a sub query with "ROW_NUMBER() OVER PARTITION"

SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'column_name' in Laravel

How can I make a full text index of the column?

Adding the custom page with add_menu_page function on Wordpress

Laravel-fopen: failed to open stream: Permission denied

how to fix Service provider class not found when using repository?

Merge column values from two arrays to form an indexed array of associative arrays

Minimum order amount except for specific shipping method in WooCommerce

How to to send mail using gmail in Laravel?

LARAVEL: How to fetch id dynamically in a query builder?

how to upload binary image to sql server using php laravel

How to show selected value using javascript in laravel

About Contact Privacy policy Terms and conditions