You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<?php
namespace App;
[...]
class Item extends Model
{
use Cloneable;
protected $cloneable_relations = ['category', 'children'];
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function category()
{
return $this->belongsTo(Category::class);
}
/**
* @return \Illuminate\Database\Eloquent\Relations\belongsToMany
*/
public function children(): belongsToMany
{
return $this->belongsToMany(Child::class)
->withPivot('value')->withTimestamps();
}
}
Now if I do Item::first()->duplicate(), the category is cloned as new row - but the children are not. I understand the docs that tell me that this is not possible on many to many: But it would be nice if it would be optional. Any ideas on that?
The text was updated successfully, but these errors were encountered:
Hello,
I got this model:
Now if I do
Item::first()->duplicate()
, thecategory
is cloned as new row - but thechildren
are not. I understand the docs that tell me that this is not possible on many to many: But it would be nice if it would be optional. Any ideas on that?The text was updated successfully, but these errors were encountered: