StoreLogMiddleware.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\http\middleware\store;
  12. use app\Request;
  13. use app\jobs\system\AdminLogJob;
  14. use crmeb\interfaces\MiddlewareInterface;
  15. /**
  16. * 操作日志记录
  17. * Class StoreLogMiddleware
  18. * @package app\http\middleware\store
  19. */
  20. class StoreLogMiddleware 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. $module = app('http')->getName();
  30. $rule = trim(strtolower($request->rule()->getRule()));
  31. //记录后台日志
  32. AdminLogJob::dispatch([$request->storeId(), $request->storeStaffInfo()['account'], $module, $rule, $request->ip(), 'store']);
  33. return $next($request);
  34. }
  35. }