<?php
namespace App\Http\Middleware;
use App\Enums\UserStatus; use Closure; use Illuminate\Http\Request; use Symfony\Component\HttpFoundation\Response;
class EnsureActiveUser { public function handle(Request $request,Closure $next):Response{$user=$request->user();if(!$user || $user->status!==UserStatus::Active || ($user->merchant && !$user->merchant->isActive())){optional($user?->currentAccessToken())->delete();return response()->json(['error'=>['code'=>'ACCOUNT_SUSPENDED','message'=>'This account is not active.']],403);}return $next($request);} }
