<?php

namespace App\Models;

use App\Enums\StockOpnameStatus;
use Dyrynda\Database\Support\CascadeSoftDeletes;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Veelasky\LaravelHashId\Eloquent\HashableId;

class StockOpname extends Model
{
    use CascadeSoftDeletes, HashableId, SoftDeletes;

    protected $table = 'stock_opname';

    protected $guarded = ['id'];

    protected $cascadeDeletes = ['items'];

    protected function casts(): array
    {
        return [
            'status' => StockOpnameStatus::class,
        ];
    }

    public function outlet(): BelongsTo
    {
        return $this->belongsTo(Outlet::class);
    }

    public function items(): HasMany
    {
        return $this->hasMany(StockOpnameItem::class);
    }
}
