->label('Contact')
->key('contact_select')
->lazy()
->relationship(
name: 'contact',
titleAttribute: 'firstname',
modifyQueryUsing: static fn (Get $get, Builder $query) => $query
->withoutGlobalScopes()
->when($get('client'), function () use ($get) {
dd($get('client')); // @todo query should restrict based on client.
}),
)
->getOptionLabelFromRecordUsing(
static fn (Contact&FullName $record): string => Str::of($record->getAttribute('fullName'))
->when($record->client?->exists, static fn (Stringable $string) => $string->append(" ({$record->client?->name})"))
->value()
)
->label('Contact')
->key('contact_select')
->lazy()
->relationship(
name: 'contact',
titleAttribute: 'firstname',
modifyQueryUsing: static fn (Get $get, Builder $query) => $query
->withoutGlobalScopes()
->when($get('client'), function () use ($get) {
dd($get('client')); // @todo query should restrict based on client.
}),
)
->getOptionLabelFromRecordUsing(
static fn (Contact&FullName $record): string => Str::of($record->getAttribute('fullName'))
->when($record->client?->exists, static fn (Stringable $string) => $string->append(" ({$record->client?->name})"))
->value()
)