30

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

xelber
  • 4,197
  • 3
  • 25
  • 33

1 Answers1

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