12345678910111213141516171819202122232425262728293031 |
- <?php
- namespace App\Http\Middleware;
- use App\Models\AdminMerchant;
- use App\Models\AdminRole;
- use App\Utils\Admin;
- use Closure;
- class MerchantMiddleware
- {
- /**
- * Handle an incoming request.
- *
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
- * @return mixed
- */
- public function handle($request, Closure $next)
- {
- if (!Admin::user()->isRole(AdminRole::ADMINISTROTOR)) {
- $merchant_id = AdminMerchant::putMerchantId();
- $is_status = AdminMerchant::query()->where(['id' => $merchant_id, 'status' => AdminMerchant::NORMAL])->first();
- if (!$is_status) {
- return response()->json(['message' => '账户已失效,请联系管理员'], 400);
- // return response()->view('admin.404');
- }
- }
- return $next($request);
- }
- }
|