<?php

declare(strict_types=1);

namespace App\Models;

use App\Models\Traits\BelongsToTenant;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;

class PatronTier extends Model
{
    use BelongsToTenant;
    use HasUuids;
    use SoftDeletes;

    protected $fillable = [
        'tenant_id', 'name', 'monthly_amount', 'benefits',
        'max_supporters', 'color', 'sort_order', 'is_active',
    ];

    protected function casts(): array
    {
        return [
            'benefits' => 'array',
            'monthly_amount' => 'integer',
            'max_supporters' => 'integer',
            'sort_order' => 'integer',
            'is_active' => 'boolean',
        ];
    }

    public function supporters(): HasMany
    {
        return $this->hasMany(PatronSupporter::class, 'tier_id');
    }
}
