Closed Mahmoudz closed 8 years ago
Can you provide more information? What Laravel version are you using?
How did you set up your environment? Did you add the Trait
? What is the output if you do dd(Permission::all(), Role::all())
? Please show a SELECT* FROM role_user;
from your database.
I'm using Laravel v5.1.34
Yes I setup the environment.
Yes I added the Trait Bican\Roles\Traits\HasRoleAndPermission
\DB::select('SELECT * FROM permission_user')
array(
)),
\DB::select('SELECT * FROM role_user')
array(
'id' => '1',
'role_id' => '1',
'user_id' => '1',
'created_at' => '2016-04-20 18:26:33',
'updated_at' => '2016-04-20 18:26:33',
)),
Permission::all()
{
"id":"1",
"name":"List users",
"slug":"list.users",
"description":"List all registered Users",
"model":null,
"created_at":"2016-04-20 18:28:08",
"updated_at":"2016-04-20 18:28:08"
}
Role::all()
{
"id":"1",
"name":"Admin",
"slug":"admin",
"description":"Admin access",
"level":"1",
"created_at":"2016-04-20 18:30:42",
"updated_at":"2016-04-20 18:30:42"
}
I'm surprised why role_user
has the data stored!! and still getting false whenever I run this dd($user->hasRole('admin'));
I have problems getting what you are doing.
Can you give me link to your project? I will clone it, set up and check local.
Make sure to set up seeders and migrations.
Hi @Isfirs thanks for your reply. It's too late! I already switched to Entrust, I think this package is prettier but I couldn't wait anymore.. I am sure I've done everything correctly! it's weird why it refused to work!! anyway I'll close this issue now. Thanks again.
I'm using version
2.1.7
I attached the role on the user but when I check if he has the role I always get false!! That's my test code: