I'm new to laravel and am successfully directing users tothe appropriate views from a controller, but in some instances I want to set an http status code, but it is always returning a response code of 200 no matter what I send.
Here is the code for my test controller function:
public function index()
{
$data=array();
return response()->view('layouts.default', $data, 201);
}
If I use the same code within a route, it will return the correct http status code as I see when I call the page with curl -I from the command line.
curl -I http://localhost/
Is there a reason why it doesn't work within a controller, but does within a route call?
I'm sure there is something I'm just misunderstanding as a newbie, but even the following code works in a route but not a controller:
public function index()
{
abort(404);
}
What am I doing wrong?