This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hi,
I want to extend User model in RainLab.User plugin to add SoftDeletes trait.
I created plugin and add that code into the plugin boot method:
UserModel::extend(function ($model)
{
// add soft deletes
}
Is it possible to do this that way?
This video only shows how to extend plugin for more fields/columns. There is no clue how to add trait to another plugin model. I suppose that is impossible, so I created new plugin. Thanks for help.
Hi,
in that time I abandoned that idea.
Now I think that this can be solved by extending User model. Something like this:
User::extend(function ($model) {
$model->implement[] = SoftDeletesBehavior::class;
}
Than you create behavior SoftDeletesBehavior
and just add SoftDeletes
trait into it. In plugin migration you will have to add deleted_at
column. Here you can read about behaviors: https://octobercms.com/docs/services/behaviors
Another option is to extend User
model and create custom model like MyUser
, but I think it is more complicated because you will need to also extend Users
controller.
Last updated
1-5 of 5