Closed iulit closed 3 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?
@zbiller Yes, I'm already aware of that. Maybe I didn't make myself understood or I might miss something. So:
Track
model has attributes
and categories
relationships. Duplicating this works well.Image
model doesn't have any relations. Duplicating this after duplicating Track
throws an exception because the code wants to also duplicate attributes
relation, which doesn't exist with the Image
model, but with the Track
model.static::$relations
from RelationHelper
class (line 211), which is not emptied when calling getModelRelations
method, thus having all the previous values.@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
Facing this issue as well. Will @iulit's solution this be adopted?
Hi @iulit @danieltov
Unfortunately this package is now discontinued. Please check out Varbox (Laravel Admin Panel) for this functionality, but much more.
Thank you!
Hello,
It seems that I cannot duplicate different model instances. Let's assume we have the following code:
The last line fails because it tries to also duplicate
$trackModel
's relationships, which is not correct. This mainly happens because in theRelationHelper
class, the relations are appended to a static property.Numa' bine ;)