how to call data from database to view by user_role laratrust

112 Views Asked by At

I use laratrust as my user role, in the user role there are 1 = superadministrator, 2 = administrator, 3 = perusahaan, then I want to display the names of existing perusahaan in my view, which means calling user = role id 3, then how to call it? I also don't really understand eloquent relationships

1

There are 1 best solutions below

0
On

You need to get users in this way

// This will return the users with 'superadministrator' role.
$users = User::whereRoleIs('superadministrator')->get();

check the documentation