<?php

namespace App\Models\Reference;

use Illuminate\Database\Eloquent\Model;

/**
 * Seeded, platform-wide locale (language/region) reference data — see
 * ReferenceDataSeeder. Global, never tenant-scoped, same as {@see Currency}.
 * Backs the Master Control "Locale" tab's locale Select with real BCP-47
 * tags instead of a free-typed field.
 */
class Locale extends Model
{
    protected $fillable = ['code', 'name', 'sort_order'];

    protected function casts(): array
    {
        return ['sort_order' => 'integer'];
    }

    /**
     * @return array<string, string>
     */
    public static function selectOptions(): array
    {
        return static::query()
            ->orderBy('sort_order')
            ->orderBy('name')
            ->pluck('name', 'code')
            ->all();
    }
}
