I want to display an array of values as options inside a select using the laravel-nova syntax. I managed to get the options rendered inside the select but the values of these options are like
<option value="2"></option>
<option value="1"></option>
<option value="0"></option>
what I want is the text as an value.
this is what I got so far:
Select::make('Slug')->options(
$this->selectOptions()
)
public function selectOptions()
{
$urls = DB::table('subpages');
$slugs = $urls->pluck('slug');
return $slugs;
}
What am I doing wrong?
Make sure to
get()
the subpages asIlluminateSupportCollection
andmapWithKeys()
to reformat the results. UsetoArray()
to provide the format Nova assumes:This is how the returned result should look like: