fix: use options instead relationship (#845)

This commit is contained in:
Scai 2024-12-27 23:14:05 +02:00 committed by GitHub
parent f684da997c
commit 66a17879a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -723,8 +723,10 @@ class EditServer extends EditRecord
->label('Database Host') ->label('Database Host')
->required() ->required()
->placeholder('Select Database Host') ->placeholder('Select Database Host')
->relationship('node.databaseHosts', 'name', ->options(fn (Server $server) => DatabaseHost::query()
fn (Builder $query, Server $server) => $query->whereRelation('nodes', 'nodes.id', $server->node_id)) ->whereHas('nodes', fn ($query) => $query->where('nodes.id', $server->node_id))
->pluck('name', 'id')
)
->default(fn () => (DatabaseHost::query()->first())?->id) ->default(fn () => (DatabaseHost::query()->first())?->id)
->selectablePlaceholder(false), ->selectablePlaceholder(false),
TextInput::make('database') TextInput::make('database')