<?php

namespace App\Modules\HR\Organization\Repositories;

use App\Modules\HR\Organization\Models\JobGrade;

class JobGradeRepository extends OrganizationRepository
{
    public function find(int $id): ?JobGrade
    {
        return JobGrade::query()->find($id);
    }

    /** @return array<int, string> */
    public function listForSelect(): array
    {
        return JobGrade::query()
            ->where('is_active', true)
            ->orderBy('level')
            ->orderBy('name')
            ->get()
            ->mapWithKeys(static fn (JobGrade $grade): array => [
                $grade->id => trim($grade->code.' — '.$grade->name),
            ])
            ->all();
    }

    protected function modelClass(): string
    {
        return JobGrade::class;
    }

    protected function relations(): array
    {
        return [];
    }
}
