Is it possible to set additional attribute when creating model from select field?

This is my code:
Select::make('client_id')
->label('Klient')
->relationship('client', 'full_name')
->options(
fn () => Client::query()
->when(auth()->user()->isBroker(), fn (Builder $query) => $query->whereBelongsTo(auth()->user(), 'broker'))
->pluck('full_name', 'id')
)
->preload()
->createOptionForm(ClientResource::getFormSchema())
->searchable(['company']),
Select::make('client_id')
->label('Klient')
->relationship('client', 'full_name')
->options(
fn () => Client::query()
->when(auth()->user()->isBroker(), fn (Builder $query) => $query->whereBelongsTo(auth()->user(), 'broker'))
->pluck('full_name', 'id')
)
->preload()
->createOptionForm(ClientResource::getFormSchema())
->searchable(['company']),
I have to set broker_id of auth()->user()->id to my Client model when is created with this select field.
1 Reply
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server