<?php

namespace App\Livewire;

use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Livewire\Component;

class Page extends Component
{
    public $slug;

    public function mount($slug): void
    {
        $this->slug = $slug;
    }

    public function render(): Factory|View
    {
        $page = \App\Models\Page::query()->where('slug', $this->slug)->firstOrFail();

        abort_if($page->is_published == false, 404);

        return view('livewire.page', [
            'page' => $page,
        ]);
    }
}
