<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

/**
 * NumerologyLetter Model
 *
 * Represents a letter in the numerological alphabet with its corresponding value.
 * Each letter (A-Z + Ñ) has a numerological value (1-9) and is marked as vowel or consonant.
 *
 * @property int $id
 * @property string $letter Letter character (A-Z, Ñ)
 * @property int $value Numerological value (1-9)
 * @property bool $is_vowel Whether the letter is a vowel
 * @property \Illuminate\Support\Carbon $created_at
 * @property \Illuminate\Support\Carbon $updated_at
 */
class NumerologyLetter extends Model
{
    use HasFactory;

    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'numerology_letters';

    /**
     * The attributes that are mass assignable.
     *
     * @var array<int, string>
     */
    protected $fillable = [
        'letter',
        'value',
        'is_vowel',
    ];

    /**
     * The attributes that should be cast.
     *
     * @var array<string, string>
     */
    protected $casts = [
        'is_vowel' => 'boolean',
        'value' => 'integer',
    ];

    /**
     * Scope to filter only vowels.
     *
     * @param \Illuminate\Database\Eloquent\Builder $query
     * @return \Illuminate\Database\Eloquent\Builder
     */
    public function scopeVowels($query)
    {
        return $query->where('is_vowel', true);
    }

    /**
     * Scope to filter only consonants.
     *
     * @param \Illuminate\Database\Eloquent\Builder $query
     * @return \Illuminate\Database\Eloquent\Builder
     */
    public function scopeConsonants($query)
    {
        return $query->where('is_vowel', false);
    }
}
