<?php

namespace App\Domains\Tenant\Controllers\AdminApp;

use App\Domains\Tenant\Models\WebsiteType;
use App\Domains\Tenant\Requests\BootstrapAdminAppRequest;
use App\Domains\Tenant\Resources\AdminApp\BootstrapAdminAppResource;
use App\Http\Controllers\Controller;

class BootstrapAdminAppController extends Controller
{
    public function __invoke(
        BootstrapAdminAppRequest $request
    ): BootstrapAdminAppResource {
        /** @var string $domain */
        $domain = $request->validated('dominio');

        return BootstrapAdminAppResource::make(
            WebsiteType::query()
                ->with('siteLogo')
                ->where('dominio', $domain)
                ->firstOrFail()
        );
    }
}
