AdminLogMiddleware.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\adminapi\middleware;
  12. use app\Request;
  13. use app\services\system\log\SystemLogServices;
  14. use crmeb\interfaces\MiddlewareInterface;
  15. /**
  16. * 日志中間件
  17. * Class AdminLogMiddleware
  18. * @package app\adminapi\middleware
  19. */
  20. class AdminLogMiddleware implements MiddlewareInterface
  21. {
  22. /**
  23. * @param Request $request
  24. * @param \Closure $next
  25. * @return mixed
  26. */
  27. public function handle(Request $request, \Closure $next)
  28. {
  29. try {
  30. /** @var SystemLogServices $services */
  31. $services = app()->make(SystemLogServices::class);
  32. $services->recordAdminLog($request->adminId(), $request->adminInfo()['account'], 'system');
  33. } catch (\Throwable $e) {
  34. }
  35. return $next($request);
  36. }
  37. }