Skip to content

How can i remove all user roles with a line code?  #1253

Closed
@haydar

Description

@haydar

Hello,

My code works correctly when like this,

$user->removeRole($user->roles->first());

But I am trying remove multiple roles like this;

$user->removeRole($user->roles);

and Laravel throwing this error message '
Return value of App\User::getStoredRole() must implement interface Spatie\Permission\Contracts\Role, instance of Illuminate\Database\Eloquent\Collection returned'

isnt there any collection support for remove role action ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions