<?php

namespace App\Livewire\Store;

use App\Models\Product;
use Livewire\Attributes\Layout;
use Livewire\Attributes\Title;
use Livewire\Component;

#[Layout('layouts.store')]
#[Title('Detail Produk')]
class ProductShow extends Component
{
    public Product $product;

    public function mount(string $slug): void
    {
        $this->product = Product::with(['category', 'partner'])
            ->where('is_active', true)
            ->where('slug', $slug)
            ->firstOrFail();
    }

    public function render()
    {
        // Selalu load ulang partner agar is_active, open_time, close_time fresh dari DB
        $this->product->load('partner');

        return view('livewire.store.product-show');
    }
}
