<?php

namespace App\Models;

use Dyrynda\Database\Support\CascadeSoftDeletes;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Veelasky\LaravelHashId\Eloquent\HashableId;

class Tier extends Model
{
    use CascadeSoftDeletes, HasFactory, HashableId, SoftDeletes;

    protected $guarded = ['id'];

    protected $cascadeDeletes = ['memberships'];

    protected function casts(): array
    {
        return [
            'min_points' => 'int',
            'max_points' => 'int',
        ];
    }

    public function memberships(): HasMany
    {
        return $this->hasMany(Membership::class);
    }

    public function rewards(): HasMany
    {
        return $this->hasMany(TierReward::class);
    }
}
