aldi N
aldi N

Reputation: 1

how to call data from database to view by user_role laratrust

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

Upvotes: -1

Views: 112

Answers (1)

Yazan Fouad Aldbaisy
Yazan Fouad Aldbaisy

Reputation: 621

You need to get users in this way

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

check the documentation

Upvotes: 0

Related Questions