neurony / laravel-duplicate

Duplicate any Eloquent model along with its underlying relationships
MIT License
121 stars 27 forks source link

Cannot duplicate different model instances #8

Closed iulit closed 3 years ago

iulit commented 4 years ago

Hello,

It seems that I cannot duplicate different model instances. Let's assume we have the following code:

$trackModel->saveAsDuplicate();
$imageModel->saveAsDuplicate();

The last line fails because it tries to also duplicate $trackModel's relationships, which is not correct. This mainly happens because in the RelationHelper class, the relations are appended to a static property.

Numa' bine ;)

zbiller commented 4 years ago

Hi @iulit

You can specify relations that you don't want to deep duplicate. Also, what's the relationship between Track and Image? Track has many Images and Image belongs to Track?

iulit commented 4 years ago

@zbiller Yes, I'm already aware of that. Maybe I didn't make myself understood or I might miss something. So:

iulit commented 4 years ago

@zbiller I added the above suggested change in a fork and everything seems to be working fine on my end now. If everything is fine, I can make a pull request.

https://github.com/iulit/laravel-duplicate/blob/master/src/Helpers/RelationHelper.php#L189

danieltov commented 3 years ago

Facing this issue as well. Will @iulit's solution this be adopted?

zbiller commented 3 years ago

Hi @iulit @danieltov

Unfortunately this package is now discontinued. Please check out Varbox (Laravel Admin Panel) for this functionality, but much more.

Thank you!