<?php

namespace Tests\Feature\Tenant;

use App\Models\Tenant;
use Closure;
use Illuminate\Http\Request;

class MockTenantMiddleware
{
    public function handle(Request $request, Closure $next)
    {
        // Skip auth for tests and set mock tenant from app instance
        $tenant = app('tenant');
        if ($tenant) {
            $request->attributes->set('tenant', $tenant);
            $request->attributes->set('tenant_id', $tenant->id);
            $request->merge(['tenant_id' => $tenant->id]);
        }
        
        return $next($request);
    }
}