• 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 render html from a @foreach loop in a textarea

Laravel Gates using model and returns "Using $this when not in object context" Line 28 of AzureUser model

PHP: Convert any string to UTF-8 without knowing the original character set, or at least try

Laravel : How to Create Dropdown to Select FOREIGN KEY from Other Table?

How can i hide dt if dd got empty value

Convert string to lowercase AND then convert it to its original form in PHP, is it possible?

Laravel Sanctum CSRF not authenticating

Redis Command To Sort Keys

WHM Enabling mod_rewrite

With doctrine ODM, can I embed many subdocuments in a main document?

image source not readable

Group data in a multidimensional array based on two columns

Artisan, creating tables in database

Assets not referencing to public folder (Laravel)

Converting IPv6 to IPv4 address in PHP

About Contact Privacy policy Terms and conditions