View Responses
Return response()
->view('hello', $data, 200)
->header('Content-Type', $type);
JSON Responses
Return response()->json([
'name' => 'Abigail',
'state' => 'CA'
]);
Return response()
->json(['name' => 'Abigail', 'state' => 'CA'])
->withCallback($request->input('callback'));
If you would like to create a JSONP response, you may use the json method in combination with the withCallback method.
File Downloads
Return response()->download($pathToFile);
return response()->download($pathToFile, $name, $headers);
return response()->download($pathToFile)->deleteFileAfterSend(true);
File Responses
Return response()->file($pathToFile);
return response()->file($pathToFile, $headers);