Laravel 5 How to get the function name of the current controller?
I often see Request $request
written this way. What is this knowledge point called?
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
public function store(Request $request)
{
//
}
Dependency injection
Assign an object to a property and call it
First question:
In Laravel
Route::current()->getActionName();
you can get the detailed name of the current Action, which may not be the result you want directly. Just process the results returned by the above method yourself.Second question:
The $request parameter here is IlluminateHttpRequest, which is passed to the Controller through dependency injection.
In Laravel, the Controller can use Request in the parameters after using IlluminateHttpRequest at the top.
Request contains the request content sent by the client.
This product uses dependency injection, which makes the performance very low