buildadmin/app/common/middleware/AdminLog.php

24 lines
523 B
PHP
Raw Normal View History

2022-03-22 15:37:38 +00:00
<?php
namespace app\common\middleware;
2022-08-23 16:27:21 +00:00
use Closure;
use Throwable;
2022-03-22 15:37:38 +00:00
use think\facade\Config;
use app\admin\model\AdminLog as AdminLogModel;
class AdminLog
{
/**
* 写入管理日志
* @throws Throwable
*/
2022-08-23 16:27:21 +00:00
public function handle($request, Closure $next)
2022-03-22 15:37:38 +00:00
{
$response = $next($request);
2022-03-22 19:21:42 +00:00
if (($request->isPost() || $request->isDelete()) && Config::get('buildadmin.auto_write_admin_log')) {
AdminLogModel::instance()->record();
2022-03-22 15:37:38 +00:00
}
return $response;
}
}