It's is showing with the brackets because it's a collection, if you want to show them in commas for example you can use the implode collection method:
{{ $user->getRoles()->implode(', ') }}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello, good day. I am starting with the use of ACL with BOUNCER. In my view blade I have something like this:
@foreach($users as $user)
{{ $user->name }}
{{ $user->getRoles() }}
@Endforeach
The above shows me the name of the user and the role or roles assigned. However these are shown as follows:
[ "RoleName1", "RoleName2" ]
Inside square brackets and double quotes.
How could I show it without the square brackets and quotes? I thank you for your help.
Regards.
You can chose between the implode or the foreach, not both at the same time:
{{ $user->getRoles()->implode(', ') }}
This will actually convert your collection ([ "RoleName1", "RoleName2" ]) to a string separated by commas (RoleName1, RoleName2).
@foreach($users as $user)
{{ $user->name }}
@foreach($user->getRoles() as $roleName) // If you use this method remove the `implode`
{{ $roleName}}
@endforeach
@endforeach
Please or to participate in this conversation.