AdminLog.php 511 B

123456789101112131415161718192021222324
  1. <?php
  2. namespace app\common\middleware;
  3. use Closure;
  4. use Throwable;
  5. use think\facade\Config;
  6. use app\admin\model\AdminLog as AdminLogModel;
  7. class AdminLog
  8. {
  9. /**
  10. * 写入管理日志
  11. * @throws Throwable
  12. */
  13. public function handle($request, Closure $next)
  14. {
  15. $response = $next($request);
  16. if (($request->isPost() || $request->isDelete()) && Config::get('buildadmin.auto_write_admin_log')) {
  17. AdminLogModel::record();
  18. }
  19. return $response;
  20. }
  21. }