• 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

find in set in laravel ? example

Find out the name of the last script that included the current one

Laravel unique validation on multiple columns

GuzzleHttp Hangs When Using Localhost

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

How to send upload image through email

How to add a heading in between checkout fields of WooCommerce

Target Laravelista is not instantiable

Laravel Nova Dependency Container what are the allowed resource properties other than id in dependsOn

Split comma separated value from table column into rows using mysql?

Require a class from another class - php

Need to display only array value in JSON output

Symfony/Form add attribute based on the data

Required field only if another field has a value, must be empty otherwise

Component install error: JInstaller: :Install: File does not exist

About Contact Privacy policy Terms and conditions