• 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

PHP Form Not Inserting

Display the WooCommerce product price inside a custom function

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

possible options to create pdf file using html elements to generate invoice in php and codeigniter

PHP: Insert marker every 3 iterations

WordPress + Nginx on non-standard port behind AWS ELB results in broken links

How to update array value in Laravel

Yii2 redirecting to previous page after login

PHP function Not Working As Expected From functions.php Include File

enable Apache http Authorization header

301 Redirect to remove query string on homepage only

How can I get data from PHP to Android TextView?

How do I loop through an MS SQL database with VB.NET?

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

In PHP, which is faster: preg_split or explode?

About Contact Privacy policy Terms and conditions