• 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 fix 'Data has already been sent to output, unable to output PDF file' in MPDF

how to see if database exists with PDO [duplicate]

VichUploaderBundle error "Expected argument of type "File", "NULL" given" when submitting the form without selecting any file

Laravel Unresolvable dependency resolving [Parameter #0 [ <required> $method ]] in class GuzzleHttpPsr7Request

dockerizing Laravel + vue

Remove product downloads section in woocommerce email notifications

PHP returning an error message and false

Elastic Beanstalk with Laravel Envoy

Adding Multiple Custom Post Types in Wordpress

php retrieve specific data onclick from database in a list format

how to hide previous markers when new markers added in google map javascript api

Laravel: Why is my variable not being set while it's in the construct function of the controller?

Laravel Carbon throws error The format separator does not match

How to use $this->session->set_userdata in codeigniter

No definition found for function in vendor vscode

About Contact Privacy policy Terms and conditions