<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
use App\Models\vendor;

class RedirectCustomDomain
{
    /**
     * Handle an incoming request.
     *
     * @param  \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response)  $next
     */
    public function handle($request, Closure $next)
    {
        // Get the custom domain
        // $customDomain = $request->getHost();

        // // Find the store associated with the custom domain
        // $store = vendor::where('custom_domain', $customDomain)->first();

        // if ($store) {
        //     // Redirect to the corresponding vendor URL
        //     $vendorUrl = "https://baye3.net/vendor/{$store->vendor_name}/{ar}";
        //     return redirect()->away($vendorUrl);
        // }

        return $next($request);
    }
}
