<?php

namespace App\Domain\Website\Models;

use App\Domain\Shared\Traits\BelongsToAcademy;
use App\Domain\Shared\Traits\HasUuid;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

class WebsiteMenu extends Model
{
    use BelongsToAcademy, HasUuid;

    protected $fillable = ['academy_id', 'key', 'name'];

    /** Top-level items only; children are loaded through the tree. */
    public function items(): HasMany
    {
        return $this->hasMany(WebsiteMenuItem::class)
            ->whereNull('parent_id')
            ->orderBy('sort_order');
    }

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

    public static function labelFor(string $key): string
    {
        return match ($key) {
            'primary' => 'القائمة الرئيسية',
            'footer' => 'قائمة التذييل',
            'footer_secondary' => 'قائمة التذييل الثانوية',
            'mobile' => 'قائمة الجوال',
            'utility' => 'قائمة مساعدة',
            default => $key,
        };
    }
}
