In the 5.5 documentation, the way to get the request is
public function index(Request $request) {
$value = $request->input('test');
$input = $request->all();
}
then there is a helper so this works too
public function index() {
$value = request('test');
$input = request()->all();
}
is there a different between the 2? Using the helper request() seems a little bit cleaner but not sure if that going to yield the same results if we make that our coding standard
I prefer using dependency injection in most cases. I had a problem using an .env.testing with the request object because the request that I was getting was the request from the application, not the one from testing. And I had a hard time finding it out what was the cause. Turns out I was using "request()" when I should have used the $request from the correct environment.
But again, edge cases. You could do just fine with "request()" and never have problems with it.