• 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

Target class controller does not exist - Laravel 8

PHP, how to convert Int value to Week days

How to get array values using foreach in laravel

Laravel Factory not calling callback 'afterCreating'

wordpress function breaks wp-admin

Auto increment id JSON

How to separate letters and digits from a string in php

Update Order custom Field value with WooCommerce REST API

PDOException SQLSTATE[HY000] [2002] No such file or directory

PHP array_filter with arguments

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

How can I format this number correctly using PHP?

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

Center point of multiple gps coordinates with php

Symfony autowiring issues since docker update

About Contact Privacy policy Terms and conditions