entrust icon indicating copy to clipboard operation
entrust copied to clipboard

Deleting a user with the SoftDelete trait in Laravel 5 will clear its roles

Open mengidd opened this issue 9 years ago • 10 comments

If you delete a user with the SoftDeletes trait in Laravel 5 while using Entrust, it will clear the roles of the user. It's not meant to, but EntrustUserTrait is not updated for Laravel 5s trait naming conventions.

Line 38-40 in EntrustUserTrait.php you can find this:

if (!method_exists(Config::get('auth.model'), 'bootSoftDeletingTrait')) {
    $user->roles()->sync([]);
}

In Laravel 5 the bootSoftDeletingTrait method was renamed to bootSoftDeletes.

Can we please get a fix for this? :)

mengidd avatar May 18 '15 11:05 mengidd

I'm gonna take a look at this

Zizaco avatar May 25 '15 00:05 Zizaco

Any solutions yet? I am also facing the same issue.

vikasddun avatar Jun 02 '15 17:06 vikasddun

It is pretty easy to resolve.. Currently i had to make a dirty hack within my model by creating a bootSoftDeletingTrait method. Until the solution is merged.

yoramdelangen avatar Jul 24 '15 15:07 yoramdelangen

Entrust doesn't have softdeletes. SoftDeletes implementation is totally different than what is described in the documentation.

hcancelik avatar Jul 28 '15 22:07 hcancelik

Hi there,

Any solution. I face the same issue here.

Thanks!

saimiris avatar Jul 04 '16 13:07 saimiris

Any solutions yet? I am facing the same problem in laravel 5.3

srtsh19 avatar Jan 25 '17 11:01 srtsh19

Same problem on 5.4

dhcmega avatar May 02 '17 19:05 dhcmega

Same problem on 5.4 as well

gabyrusu avatar May 08 '17 07:05 gabyrusu

Same problem on 5.5 as well

rojonunoo avatar Feb 19 '18 02:02 rojonunoo

Same problem on 5.6 as well

AnasSafi avatar Jul 18 '18 09:07 AnasSafi