• 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

woocommerce_wp_select options array from product attribute terms

Extract string between first whitespace and last whitespace in php

How can I get data from PHP to Android TextView?

How to increase the PHP upload limits [duplicate]

Exception thrown during the rendering of a template("Parameter "id" for route "url" must match "[^/]++" ("" given) to generate a corresponding URL.")

How to get Laravel's CSRF Token from Another Website?

image source not readable

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

nginx err_connection_refused, can anyone help me?

Unable to uninstall brew php from homebrew

Laravel 5.1 Unknown database type enum requested

How to read laravel_session cookies saved in cookie memory of browser in client side?

How To Access A Column In M-M Relationship Table In Laravel

How can I remove the "Advanced" panel of all blocks in WordPress block editor?

PHP Include for HTML?

About Contact Privacy policy Terms and conditions