<?php

namespace App\Livewire;

use App\Models\Category;
use Livewire\Component;

class Blog extends Component
{
    public $postDetail;

    public $category;

    public function mount($slug): void
    {
        $this->postDetail = \App\Models\Blog::query()->where('slug', $slug)->firstOrFail();
        $this->category = Category::query()->where('id', $this->postDetail->category_id)->first();
    }

    public function render()
    {
        return view('livewire.blog')->with('postDetail', $this->postDetail)->with('category', $this->category);
    }
}
