$roles=Auth::user()->roles->map(function($role) { return $role->id;})
或者直接获取中间表的role_id:
foreach (Auth::user()->roles as $role) { echo $role->pivot->role_id;}
$roles=Auth::user()->roles->map(function($role) { return $role->id;})
或者直接获取中间表的role_id:
foreach (Auth::user()->roles as $role) { echo $role->pivot->role_id;}
精彩评论