Basically, every time a controller method runs I call an event:
public function destroy(User $user) { event(new AdminActivity('admin.users.destroy',class_basename(Route::current()->controller),'destroy','DELETE')); ... }
In fact it is saving this information:
event(new AdminActivity(ROUTE_NAME,CONTROLLER_NAME,CONTROLLER_METHOD_NAME,CONTROLLER_METHOD_TYPE));
Now I want to automatically pass the required parameters instead of passing them manually.
So I need to get route name , controller method name and controller method type auto (like class_basename(Route::current ()->controller)
Returns the controller name).
So what should I do?
You can pass
Route::current()
to the event and then get the information you need from the\Illuminate\Routing\Route
objectThen, in your
AdminActivity
event classNote: The return type of
$route->methods()
is an array, containing all valid request methods (GET, HEAD, POST...)