<?php

namespace Modules\Bms\Entities;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class BmsAddon extends Model
{
    protected $table = 'bms_addons';

    protected $fillable = [
        'business_id', 'product_id', 'variation_id', 'name', 'name_ar',
        'category', 'description', 'price', 'unit', 'is_active', 'sort_order',
    ];

    protected $casts = [
        'price'      => 'decimal:2',
        'is_active'  => 'boolean',
        'sort_order' => 'integer',
    ];

    public function halls(): BelongsToMany
    {
        return $this->belongsToMany(BmsHall::class, 'bms_hall_addon', 'addon_id', 'hall_id')
            ->withPivot(['price_override', 'is_available'])
            ->withTimestamps();
    }
}
