Laravel 5 controller sending JSON integer as string
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);