F
Filament16mo ago
Ander

get element of array, not index

How can I get the element of the index of the array of a select. The $state only returns the index of the array but I also need the element . For example, the values ​​are: [ 'A' => 'Example 1', 'B' => 'Example 2' ]. I want to get "Example 1", but I don't want to modify 'A', otherwise I would put something like 'Example 1' => 'Example 1'.
Select::make('job_id')->label(__('employees.job_id'))
->options(Job::get()->pluck('name', 'id'))->searchable() ->afterStateUpdated(
function($state)
{
**\Log::alert($state); //return INDEX
//I want to get element
//$set('test', I want to get element);**
}),
Select::make('job_id')->label(__('employees.job_id'))
->options(Job::get()->pluck('name', 'id'))->searchable() ->afterStateUpdated(
function($state)
{
**\Log::alert($state); //return INDEX
//I want to get element
//$set('test', I want to get element);**
}),
2 Replies
Dan Harrin
Dan Harrin16mo ago
Job::find($state)->name
Ander
AnderOP16mo ago
thanks you
Want results from more Discord servers?
Add your server