hpbyte / edms

An Electronic Document Management System for Universities using Laravel
51 stars 39 forks source link

How to assign Root to a user #3

Open rustwayne opened 5 years ago

rustwayne commented 5 years ago

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

alrasyidin commented 4 years ago

how to assign role to user base on file role_permission.txt where i must put it?

nicholasliversage commented 3 years ago

Did you figure out where to put it?

ikur007 commented 2 years ago

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

same, how to configure root user?