MerchantMiddleware.php 870 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace App\Http\Middleware;
  3. use App\Models\AdminMerchant;
  4. use App\Models\AdminRole;
  5. use App\Utils\Admin;
  6. use Closure;
  7. class MerchantMiddleware
  8. {
  9. /**
  10. * Handle an incoming request.
  11. *
  12. * @param \Illuminate\Http\Request $request
  13. * @param \Closure $next
  14. * @return mixed
  15. */
  16. public function handle($request, Closure $next)
  17. {
  18. if (!Admin::user()->isRole(AdminRole::ADMINISTROTOR)) {
  19. $merchant_id = AdminMerchant::putMerchantId();
  20. $is_status = AdminMerchant::query()->where(['id' => $merchant_id, 'status' => AdminMerchant::NORMAL])->first();
  21. if (!$is_status) {
  22. return response()->json(['message' => '账户已失效,请联系管理员'], 400);
  23. // return response()->view('admin.404');
  24. }
  25. }
  26. return $next($request);
  27. }
  28. }