Since the roles and permissions are fixed you don't want to fetch them every time render is called. Initialize two public properties inside mount() instead.
What exactly is your problem? You don't see the roles and permissions in your view?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm on Laravel 8 / Livewire and in the process of building the user management module in my app.
On my form, below the general fields such as name, email and phone. I want to have two groups of checkboxes that will display the available roles and permissions.
In the component, I have my render method like this:
public function render()
{
// $roles = Role::all();
// dd($roles); <- this shows all of the roles
return view('livewire.admin.users', [
'roles' => Role::all(),
'permissions' => Permission::all(),
'users' => User::with('roles')->latest()->orderBy('id', 'ASC')->paginate($this->perPage),
]);
}
I'm only having issues with passing Roles and Permissions to the view. 'users' works fine and I can iterate over the users variable.
Any thoughts on what the issue might be?
Since the roles and permissions are fixed you don't want to fetch them every time render is called. Initialize two public properties inside mount() instead.
What exactly is your problem? You don't see the roles and permissions in your view?
Please or to participate in this conversation.