<?php

namespace Modules\Bms\Entities;

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

class BmsPackageItem extends Model
{
    protected $table = 'bms_package_items';

    protected $fillable = [
        'business_id', 'package_id', 'product_id', 'variation_id',
        'name', 'name_ar', 'description', 'description_ar', 'media', 'options', 'contents',
        'category', 'quantity', 'qty_mode', 'unit_cost', 'addon_price',
        'is_optional', 'is_addon', 'sort_order',
    ];

    protected $casts = [
        'quantity'    => 'decimal:2',
        'unit_cost'   => 'decimal:2',
        'addon_price' => 'decimal:2',
        'is_optional' => 'boolean',
        'is_addon'    => 'boolean',
        'media'       => 'array',
        'options'     => 'array',
        'contents'    => 'array',
        'sort_order'  => 'integer',
    ];

    public function package(): BelongsTo
    {
        return $this->belongsTo(BmsPackage::class, 'package_id');
    }
}
