According to the Laravel documentation Request is acquired via dependency injection. For a controller this is fine, but how do we access Request object outside a controller, for example in a view
Asked
Active
Viewed 3.2k times
1 Answers
74
There is request helper in laravel. You can use Request Object anywhere. For example
request()->field_name
Here's laravel documentation link for request helper https://laravel.com/docs/5.2/helpers#method-request

PHP Worm...
- 4,109
- 1
- 25
- 48

Bishnu Bhusal
- 1,078
- 9
- 11
-
5This doesn't work in lumen :/ You have to use `app()->request`. Look [Helpers.php](https://github.com/laravel/lumen-framework/blob/6.x/src/helpers.php) – UselesssCat Nov 21 '19 at 22:03
-