I create all model and relations . one user have many Roles and one Role have many Permissions. i want a elequent that give a user with all roles and all permission for per role.
Asked
Active
Viewed 240 times
0
-
get all information about the logged in user information by `dd(Auth::user())` then you can choose any individual information by calling property like `Auth::user()->id` – Md. Abutaleb Dec 12 '16 at 08:00
-
I dont have Auth. I'm creating Api with jwt. and i want one sentence. – Hamid Naghipour Dec 12 '16 at 08:08
1 Answers
0
now I create one function for this :
public function getUserByMobileNumberWithRolesAndPermissions($mobile_number)
{
$users = user::with('roles.permissions')->whereMobileNumber($mobile_number)->first();
return is_null($users) ? null : $users->toArray();
}

Hamid Naghipour
- 3,465
- 2
- 26
- 55