F
Filamentβ€’10mo ago
Diogo Pinto

Adding relationship manager to livewire

Hello all, Is there a painless way to add a Relationship Manager to a custom livewire component? Use cases: - A edit profile page with an address (belongstomany) relationship - user can attach and detach addresses Thanks!
Solution:
Relation Managers are Livewire components. You could add them to the view file.
Jump to solution
4 Replies
Solution
Dennis Koch
Dennis Kochβ€’10mo ago
Relation Managers are Livewire components. You could add them to the view file.
Diogo Pinto
Diogo PintoOPβ€’10mo ago
Thanks @Dennis Koch, I was wondering if there was an easier way, but I went with your way! Thanks so much! For those wondering, here's the solution: In your view:
<x-filament-panels::resources.relation-managers :active-manager="$this->activeRelationManager ?? array_key_first($relationManagers)" :managers="$relationManagers" :owner-record="$this->getRecord()"
:page-class="static::class" />
<x-filament-panels::resources.relation-managers :active-manager="$this->activeRelationManager ?? array_key_first($relationManagers)" :managers="$relationManagers" :owner-record="$this->getRecord()"
:page-class="static::class" />
Then in your livewire component, you just need to define public $activeRelationManager (object), $relationManagers (array) and getRecord()
Dennis Koch
Dennis Kochβ€’10mo ago
Not really. You cannot embed them in Forms, because they contain forms themselves. So the only solution is via the view
Diogo Pinto
Diogo PintoOPβ€’10mo ago
You guys made us lazy. We expect an easy fix for everything, because filaments makes us cut some many corners. Thank you for the support! πŸ™πŸ»

Did you find this page helpful?