Hello,
I got this model:
<?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?
Hello,
I got this model:
Now if I do
Item::first()->duplicate(), thecategoryis cloned as new row - but thechildrenare 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?