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
I have installed this awesome package, then I used Cloneable trait in User model. I have Post model also and every user hasMany posts and every post belongsTo one user WITH a unique title....as my code show
...classUserextendsAuthenticatable
{
....
useCloneable;
/** * The attributes that are mass assignable. * * @var array */protected$fillable = [
'name', 'email', 'password',
];
...
protected$cloneable_relations = ['posts'];
publicfunctionposts()
{
return$this->hasMany(Post::class, 'user_id', 'id');
}
}
When I try to clone the post, this operation is successful, BUT when I try to clone the user this ERROR SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'testing' for key 'posts_title_unique' (SQL: insert into 'posts' ('title', 'body', 'user_id', 'updated_at', 'created_at') values (testing, wesdfdsfffsdf, 54, 2021-07-14 15:00:54, 2021-07-14 15:00:54)) triggered
I know that the solution is to try to change the title while cloning, BUT I do NOT know how can I do it (I have tried onCloning() method BUT WITHOUT avail)
The text was updated successfully, but these errors were encountered:
Welcome,
I have installed this awesome package, then I used
Cloneable
trait inUser
model. I havePost
model also and every user hasMany posts and every post belongsTo one user WITH a unique title....as my code showWhen I try to clone the post, this operation is successful, BUT when I try to clone the user this ERROR
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'testing' for key 'posts_title_unique' (SQL: insert into 'posts' ('title', 'body', 'user_id', 'updated_at', 'created_at') values (testing, wesdfdsfffsdf, 54, 2021-07-14 15:00:54, 2021-07-14 15:00:54))
triggeredI know that the solution is to try to change the title while cloning, BUT I do NOT know how can I do it (I have tried
onCloning()
method BUT WITHOUT avail)The text was updated successfully, but these errors were encountered: