<?php

namespace App\Models;

use Dyrynda\Database\Support\CascadeSoftDeletes;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Veelasky\LaravelHashId\Eloquent\HashableId;

class Warehouse extends Model
{
    use CascadeSoftDeletes, HasFactory, HashableId, SoftDeletes;

    protected $guarded = ['id'];

    protected $cascadeDeletes = ['perfumes', 'products', 'bottles', 'purchases', 'restocks'];

    public function bottles(): BelongsToMany
    {
        return $this->belongsToMany(Bottle::class)->withPivot('stock');
    }

    public function perfumes(): BelongsToMany
    {
        return $this->belongsToMany(Perfume::class)->withPivot('stock');
    }

    public function products(): BelongsToMany
    {
        return $this->belongsToMany(Product::class)->withPivot('stock');
    }

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

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