<?php

namespace App\Models;

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

class SerenataPackage extends Model
{
    protected $fillable = [
        'organization_id',
        'mariachi_group_id',
        'name',
        'city',
        'base_price',
        'internal_cost',
        'commission_amount',
        'gift_codes',
        'artist_codes',
        'other_cost_codes',
        'is_active',
        'is_default',
        'sort_order',
    ];

    protected $casts = [
        'organization_id' => 'integer',
        'mariachi_group_id' => 'integer',
        'base_price' => 'float',
        'internal_cost' => 'float',
        'commission_amount' => 'float',
        'gift_codes' => 'array',
        'artist_codes' => 'array',
        'other_cost_codes' => 'array',
        'is_active' => 'boolean',
        'is_default' => 'boolean',
        'sort_order' => 'integer',
    ];

    public function priceRules(): MorphMany
    {
        return $this->morphMany(CatalogPriceRule::class, 'priceable');
    }

    public function mariachiGroup()
    {
        return $this->belongsTo(MariachiGroup::class);
    }
}
