'How to get query log of events run by admins
I want to get all the queries that run by each Admin of my website.
I mean I need to get the url of the page that they're running query and also their user id and ip address.
But for doing this, I don't want to use Controller methods.
I need to do this as Middleware and apply it to all admin routes.
So how can I do this?
Would you please provide me some tips or guidelines about this?
Solution 1:[1]
In the first flow, you have to create a custom middleware using this command
php artisan make:middleware Admin
Then add middle route in kernal file :- app >> Http >> Kernel.php
Add this in $routeMiddleware array
protected $routeMiddleware = [
'admin' => \App\Http\Middleware\Admin::class,
];
after that add this admin route middleware to our route
Route::get('admin/routes', 'HomeController@admin')->middleware('admin');
You can put your logic in this controller, so whenever any route call from this inside this route first call our middleware
For more explanation reference the below link :
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Shravan Goswami |
