Laravel access request object outside the controller

According to the document, a Laravel Request is requested through dependency injection. This is normal for the controller, but how do we access the Request object outside the controller, for example, in the view

+6
source share
1 answer

Laravel has a request helper. You can use the Request object anywhere. for instance

request()->field_name 

Here's the laravel documentation link for the helper request https://laravel.com/docs/5.2/helpers#method-request

+16
source

All Articles