Laravel - Responses - View Responses

If you need control over the response's status and headers but also need to return a view as the response's content, you should use the view method:

    return response()
                ->view('hello', $data, 200)
                ->header('Content-Type', $type);

Of course, if you do not need to pass a custom HTTP status code or custom headers, you may use the global view helper function.