laravel request json code example
Example 1: php laravel return json response
return response()->json([
'name' => 'Abigail',
'state' => 'CA'
]);
Example 2: laravel return response json
return response()->json([
'name' => 'Abigail',
'state' => 'CA',
]);
Example 3: ensure a header is included with request laravel
// Returns header value with default as fallback
$request->header('someHeader', 'defaultValue');
// Returns boolean
$request->headers->has('someHeader');