Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel access request object outside controller

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

like image 400
xelber Avatar asked Jul 12 '16 03:07

xelber


1 Answers

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

like image 175
Bishnu Bhusal Avatar answered Oct 16 '22 08:10

Bishnu Bhusal