<?php

declare(strict_types=1);

namespace App\Filament\Components\Form;

use App\Filament\Support\SelectOptionLabels;

use Filament\Forms\Components\Select;
use Illuminate\Support\Facades\Auth;

class CreatedBySelect extends Select
{
    public static function create(): static
    {
        return parent::make('created_by')
            ->label('ایجادکننده')
            ->relationship('createdBy', 'name')
            ->getOptionLabelFromRecordUsing(fn ($record) => SelectOptionLabels::user($record))
            ->searchable(['name', 'cellphone'])
            ->preload()
            ->default(Auth::id())
            ->hidden()
            ->columnSpanFull();
    }
}
