how to show Permissions in vue with laravel?

1

I have brought data from the user model and I have laravel permission but when I bring them, I can not show only the name of the role in my veu component, I have my partner as follows

           <tr v-for="user in users"  :key="user.id">
            <td>{{user.id}}</td>
            <td>{{user.name}}</td>
            <td>{{user.email}}</td>
            <td>{{user.created_at}}</td>
            <td >{{user.roles}}</td>
           </tr>

My controller brings the information as follows:

             $users = User::with('roles')->get();
             return ['users' => $users];

and it shows me the following

I have also tried using the following but the records disappear

  <td >{{user.roles.name}}</td>
    
asked by yamile ibarra 01.10.2018 в 23:22
source

1 answer

1

I found the answer, just add to the source of the subvector to which you are referring it to go through it and finally tell it what field of that subvector you are going to show

<td v-for="name in user.roles">{{name.name}}</td>
    
answered by 02.10.2018 / 18:14
source