<?php
namespace App\Http\Middleware;use App\Support\ApiResponse;use Closure;use Illuminate\Http\Request;use Symfony\Component\HttpFoundation\Response;
final class EnsureOperator {public function handle(Request $r,Closure $next):Response{$allowed=array_filter(array_map('trim',explode(',',(string)config('gateway.operator_emails',''))));if(!$r->user()||!in_array(strtolower($r->user()->email),array_map('strtolower',$allowed),true))return ApiResponse::error('FORBIDDEN','Authorized operator access is required.',403);return $next($r);}}
