Simple question, I think.
I have a route that calls a function in a controller. In that controller, I have a call to another controller function.
For example:
$_testing = with(new TestingController)->prepwork($variable1,$variable2);
Inside of TestingController prepwork(), if a condition matches, I
return Response::view(...);
Question - how come that isn't enough? the return just returns control back to the calling function (which makes sense), but how do I tell Laravel - stop what you are doing and output that view.
To make it work, I have to:
$_testing = with(new TestingController)->prepwork($variable1,$variable2);
return $_testing;
That doesn't really work as the prepwork is designed to do some heavy lifting and then output a result model. The view is only kicked off when there is an error.
And YES - I know I can do something like this:
if ($_testing->whatImCheckingForErrors) { return Response::view(...); }
I'm just trying to understand why the return Response::view doesn't end the processing... If that makes sense.
Only the very last return will end processing, because the application will receive this last return and render whatever you send in it.
If you call a method (1), that calls another method (2), that calls a third one (3), Laravel app will receive the View only when your return back from (1).
That's why when you added that last return it worked.
There are things you can do, like:
echo Response::view(...);
die;
It may work sometimes, but
BUT THIS IS REALLY BAD, DO NOT DO THIS UNLESS YOU'RE JUST TESTING THINGS!
Because Laravel won't be able to close everything and flush whatever it needs to and you can compromise your application and even server.