I have table called technologies which has id, name, description and I am displaying this using checkboxlist like below
CheckboxList::make('technologies')
->required()
->relationship(titleAttribute: 'name');
Since CheckboxList can also display description, I want it to display my technologies description as well, I try like below
->descriptions(fn() => Technologies::pluck('description', 'id')->toArray());
And yes this introduce duplicate query, and I cannot use fn(Model $record) because of relationships (maybe)
I call this from UserForm, and users -> technologies relationships is
public function technologies(): BelongsToMany
{
return $this->belongsToMany(Technology::class);
}
So, how can I display correct description on checkboxlist descriptions without duplicate query and thanks in advance