Maslosoft / Mangan

MongoDB Object Persister/ODM
https://maslosoft.com/mangan/
Other
5 stars 0 forks source link

parentId might not be saved #72

Closed pmaselkowski closed 6 years ago

pmaselkowski commented 8 years ago

Scenario:

$model = new Asset
$model->file = new Image
$model->save()

Then

$file = ...find file...
$file->parentId; // Should point to Asset, but does not.
pmaselkowski commented 8 years ago

Possibly should rely on #15

pmaselkowski commented 8 years ago

Another option is to use event on trait

pmaselkowski commented 7 years ago

Breaks Event/ParentChildTrashable

pmaselkowski commented 6 years ago

This must be registered manually, as it relies on owner save. And there is no way to tell if class property is somehow connected to other class.

However there is a helper class to address this issue:

 Maslosoft\Mangan\Events\Handlers\ParentChildTrashHandler