F
Filament13mo ago
Azorky

Relation manager attach one-to-many

I have a relation manager between projects and purchace_invoices (one-to-many). In the relation manager I want to be able to attach existing purchase invoices to a project, but I cant see to figure out how.
Solution:
``` Action::make('aankoopfactuurKoppelen') ->color('gray') ->form([ Select::make('id')...
Jump to solution
3 Replies
Azorky
AzorkyOP13mo ago
No description
Azorky
AzorkyOP13mo ago
Here I want to have an attach button to add new existing invoices (that are not linked to other projects) to the project. But it seems like attach and associate only works for many to many?
No description
Solution
Azorky
Azorky13mo ago
Action::make('aankoopfactuurKoppelen')
->color('gray')
->form([
Select::make('id')
->label('Purchase Invoice')
->options(PurchaseInvoice::query()->pluck('invoice_number', 'id'))
->native(false)
->multiple()
->searchable()
->required(),
])
->action(function (array $data): void {
PurchaseInvoice::whereIn('id', $data['id'])->update(['project_id' => $this->ownerRecord->id]);
})
Action::make('aankoopfactuurKoppelen')
->color('gray')
->form([
Select::make('id')
->label('Purchase Invoice')
->options(PurchaseInvoice::query()->pluck('invoice_number', 'id'))
->native(false)
->multiple()
->searchable()
->required(),
])
->action(function (array $data): void {
PurchaseInvoice::whereIn('id', $data['id'])->update(['project_id' => $this->ownerRecord->id]);
})
This fixed it
Want results from more Discord servers?
Add your server