<?php

namespace App\Models;

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

class ArtistItem extends Model
{
    public const TYPE_INCLUDED = 'included';
    public const TYPE_ADDITIONAL = 'additional';

    protected $fillable = [
        'organization_id',
        'mariachi_group_id',
        'code',
        'name',
        'type',
        'internal_cost',
        'base_price',
        'is_active',
        'sort_order',
    ];

    protected $casts = [
        'organization_id' => 'integer',
        'mariachi_group_id' => 'integer',
        'internal_cost' => 'float',
        'base_price' => 'float',
        'is_active' => 'boolean',
        'sort_order' => 'integer',
    ];

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

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

    public static function defaultCatalog(): array
    {
        return [
            ['code' => 'cantante', 'name' => 'Cantante', 'type' => self::TYPE_INCLUDED, 'internal_cost' => 35000, 'base_price' => 35000, 'sort_order' => 10],
            ['code' => 'vihuela', 'name' => 'Vihuela', 'type' => self::TYPE_INCLUDED, 'internal_cost' => 35000, 'base_price' => 35000, 'sort_order' => 20],
            ['code' => 'guitarron', 'name' => 'Guitarrón', 'type' => self::TYPE_INCLUDED, 'internal_cost' => 35000, 'base_price' => 35000, 'sort_order' => 30],
            ['code' => 'trompeta', 'name' => 'Trompeta', 'type' => self::TYPE_INCLUDED, 'internal_cost' => 40000, 'base_price' => 40000, 'sort_order' => 40],
            ['code' => 'violin', 'name' => 'Violín', 'type' => self::TYPE_INCLUDED, 'internal_cost' => 35000, 'base_price' => 35000, 'sort_order' => 50],
            ['code' => 'voz_femenina', 'name' => 'Voz femenina', 'type' => self::TYPE_ADDITIONAL, 'internal_cost' => 50000, 'base_price' => 50000, 'sort_order' => 60],
        ];
    }
}
