FilamentF
Filamentβ€’6mo ago
Adam Holmes

Observing models and relationships

Hi,

I have 2 models for example say Library and Book. On my Library create page I can select the books that belong to this library. When I save the library, the books are also saved in the relationship table.

I have a LibraryObserver so that I can perform some processing when it is created - however, the processing involves the books too.

The issue I have is that in the public function created(Library $library) method of my LibraryObserver the relationship doesn't exist yet (presumably because it hasn't been saved at this point - because we're firing on the Library created event).

Anyone have any ideas how I can get around this?

One option is to add all the logic into the form schema in the after create (I think) but I'd like it to be centralised logic rather that attached to the form.

Thanks in advance πŸ™‚
Was this page helpful?