• 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

Laravel/docker-compose/redis - Class 'Redis' not found

Get image type from base64 encoded src string

Alert message after submitting form in PHP

best way to store error messages in Laravel (session or variable)

set mail driver dynamically from database for different email in notification

Laravel Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) on a sub query with "ROW_NUMBER() OVER PARTITION"

How to get rid of ampersand using WP Nonce URL and WP Redirect or PHP header

Is there a way to use the same parameter into multiple place in the same query with Eloquent? [duplicate]

Unable to match results of php hash_hmac() and coldfusion hmac()

Laravel: HTML in notification

Server-sent events in PHP (without echo or print)

How to add a custom field to all Woocommerce attribute terms using add_action

Laravel no logout option from menu after successfull login

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

How to set dynamic `home` and `siteurl` in WordPress?

About Contact Privacy policy Terms and conditions