mercredi 16 novembre 2016

Cant access relations in 'created' Model Event?

Could someone please clarify this? I've used Model Events a lot of times before but it seems I haven't tried to access an related models on the initial "created" Event. For example, I have two Models in a M2M relation to each other:

Book() public function authors()
Author() public function books()

I would like to be able to update some fields in the related objects like this:

Book::created($book)
$authors = $book->authors

..but the result has no related objects. If this is the usual behaviour (and I haven't done something incorrect here) is there a way to get access to the relations on initial creation/saving?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire