Level 88
You can do something like this
$currentRoles = $user->roles->pluck('id');
$availableRoles = Role::whereNotIn('id', $currentRoles)->get();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
How can I get all the roles for a user which are not assigned to that user ?
You can do something like this
$currentRoles = $user->roles->pluck('id');
$availableRoles = Role::whereNotIn('id', $currentRoles)->get();
Please or to participate in this conversation.