如何获取由管理员运行的事件的查询日志

发布于 2025-01-27 08:51:06 字数 178 浏览 4 评论 0原文

我想获取由我网站的每个管理员运行的所有查询。

我的意思是,我需要获取他们正在运行查询以及其用户ID和IP地址的页面的URL。

但是为此,我不想使用控制器方法。

我需要作为中间件执行此操作,并将其应用于所有管理路线。

那我该怎么做呢?

您能为我提供一些有关此的提示或指南吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

丿*梦醉红颜 2025-02-03 08:51:06

在第一个流中,您必须使用此命令创建自定义中间件

php artisan make:middleware Admin
 

,然后在内核文件中添加中间路由: - app>> http>> kernel.php

将其添加到$ utaremiddleware阵列

protected $routeMiddleware = [
    'admin' => \App\Http\Middleware\Admin::class,
];

之后,此之后,将此管理路由中间件添加到我们的路由中,

 Route::get('admin/routes', 'HomeController@admin')->middleware('admin');

您可以将逻辑放入此控制器中,因此,每当从该路由中的任何路由从此路线中调用任何路由时,请先致电我们的中间件

以获取更多说明,以获取以下链接:

  1. https://laravel.com/docs/docs/9.x/middleware


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 :

  1. https://laravel.com/docs/9.x/middleware

  2. https://appdividend.com/2022/01/23/laravel-middleware/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文