<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class InventoryCategory extends Model
{
    use HasFactory, SoftDeletes;

    protected $fillable = [
        'name',
        'description',
        'status',
        'restaurant_id',
        'is_default',
    ];

    protected $casts = [
        'status' => 'string',
        'is_default' => 'boolean',
    ];

    public function items()
    {
        return $this->hasMany(Item::class, 'category_id');
    }

    public function inventories()
    {
        return $this->hasMany(Inventory::class, 'category_id');
    }

    public function restaurant()
    {
        return $this->belongsTo(Restaurant::class, 'restaurant_id');
    }

    public function scopeForRestaurant($query, $restaurantId)
    {
        return $query->where('restaurant_id', $restaurantId);
    }
}
