• 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

Having trouble with PDO queries (Notice: Undefined index)

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

How to skip cart page on woocomerce for certain products only?

How to reset Laravel AuthManager/guards in between API calls in tests?

How to programmatically find public properties of a class from inside one of it's methods

Why isn't my PHP exception working?

VB.NET WebRequest with PHP POST

Getting public posts of a random user from Facebook API

Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables 11 [closed]

TesseractOCR not working for Laravel

target [LaravelFortifyContractsRegisterViewResponse] is not instantiable

How to create custom authentication in laravel 8?

MySQL upgrade causing unexpected results on simple WHERE clauses

Transpose and flatten multiple rows of array data [duplicate]

Laravel Unknown Column 'updated_at'

About Contact Privacy policy Terms and conditions