Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

How to assign Root to a user  #3

@rustwayne

Description

@rustwayne

What I try to do :


use App\User
use Spatie\Permission\Models\Role

$u1 = User::find(1)
$u2 = User::find(2)
$u3 = User::find(3)

$r1 = Role::where('name','Root')->first() 
$r2 = Role::where('name','Admin')->first()
$r3 = Role::where('name','User')->first()

$u1->assignRole($r1)
$u2->assignRole($r2)
$u3->assignRole($r3)


The Error I get :
TypeError: Return value of App\User::getStoredRole() must implement interface Spatie\Permission\Contracts\Role

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions