<?php

namespace App\Http\Controllers;

use App\Domains\Bio\Models\BioPage;
use App\Domains\Domain\Models\Domain;
use Illuminate\Http\Response;
use Illuminate\View\View;

class BioPageController extends Controller
{
    public function show(string $slug): View|Response
    {
        $host = request()->getHost();
        $domain = Domain::where('hostname', $host)->first();

        $page = BioPage::where('slug', $slug)
            ->where('domain_id', $domain?->id)
            ->where('is_published', true)
            ->with('blocks')
            ->firstOrFail();

        return view('bio.show', compact('page'));
    }
}
