• 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

Confirm Leave on External Links in Wordpress

Yii Ajax Submit button

Update Order custom Field value with WooCommerce REST API

How to use PHPCBF to fix one issue at a time?

Transform array, set each array element with parent key php

How to delete old images from public folder on update using Laravel

How to fix this error : Ask your hosting provider to use PHP 7.2.5 or higher for both HTTP and CLI?

How to add a heading in between checkout fields of WooCommerce

Batch request Google Calendar php API

Testing subscription renewals on Stripe

Call to a member function givePermissionTo() on null

I need to link Google Sheet with my Laravel

Woocommerce Checkout - Add conditional field required if one field is filled

SQLSTATE[HY000]: General error: 1 table posts has no column named *

php echo remove slashes from url [duplicate]

About Contact Privacy policy Terms and conditions