laravel response 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: response()->json(['data' => $allCheaters]) not getting back

return response()->json(['name' => 'Abigail', 'state' => 'CA']);

Example 4: Laravel json response

return response()->json($array);

Example 5: laravel return response view

return response()->view('your_view', compact('variableName'));