<?php

namespace App\Livewire\Studio\Manage\StockOpname;

use App\Models\StockOpname;
use App\Models\StockOpnameItem;
use App\Traits\Authorization\WithAuthorization;
use Illuminate\Contracts\View\View;
use Illuminate\Database\Eloquent\Collection;
use Livewire\Attributes\Title;
use Livewire\Component;

#[Title('Lihat Stock Opname')]
class Show extends Component
{
    use WithAuthorization;

    public Collection $items;

    public StockOpname $stockOpname;

    public function mount(StockOpname $stockOpname): void
    {
        $this->items = StockOpnameItem::with('itemable')
            ->where('stock_opname_id', $stockOpname->id)
            ->get();

        $this->stockOpname = $stockOpname;
    }

    public function render(): View
    {
        return view('livewire.studio.manage.stock-opname.show', [
            'pageTitle' => 'Lihat Stock Opname',
        ]);
    }
}
