• 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

Symfony - "framework.test" config is not set to true

laravel sanctum Route [login] not defined

How to install PHP composer inside a docker container

How to average columns of data from multiple, flat arrays?

Trying to iterate over a mongodb cursor twice - failing

if statement inside concatenation

Sync Records With Default Values in Pivot Tables, Call to undefined method syncWithPivotDefaults()

I want a way to give path to my files which are outside of public folder in laravel

Laravel - Browser displays message again when I press back button

mysql_result is defined but mysql_free_result warns it expected a resource

How to change the app environment at run time?

Send POST data via raw JSON with Postman

Generate random username based on full name php

phpunit - testing is painfully slow

PHP: How to raise number to (tiny) fractional exponent?

About Contact Privacy policy Terms and conditions