title: Laravel 6 in index blade how can I show only users who have roles and their roles in the table
body: <p>In index.blade.php, I wrote these codes to show users who have roles</p>
  <pre><code>&lt;thead&gt;
      &lt;tr&gt;
          &lt;th scope=&quot;col&quot;&gt;Name&lt;/th&gt;
          &lt;th scope=&quot;col&quot;&gt;Email&lt;/th&gt;
          &lt;th scope=&quot;col&quot;&gt;Roles&lt;/th&gt;
          &lt;th scope=&quot;col&quot;&gt;Actions&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      @foreach($users as $user)
          &lt;tr&gt;
              &lt;td&gt;{{ $user-&gt;name }}&lt;/td&gt;
              &lt;td&gt;{{ $user-&gt;email }}&lt;/td&gt;
              &lt;td&gt;{{ $user-&gt;roles }}&lt;/td&gt;
              &lt;td&gt;Show&lt;/td&gt;
          &lt;/tr&gt;
      @endforeach
  &lt;/tbody&gt;
  </code></pre>
  <p>And I wrote these codes in UserController,</p>
  <pre><code> $userId = \DB::table('role_user')-&gt;get()-&gt;pluck('user_id');
   $users = User::find($userId);
  
   return view('admin.index', compact('users'));
  </code></pre>
  <p>And I got these in the website:</p>
  <pre><code>[{&quot;id&quot;:1,&quot;name&quot;:&quot;User Administrator&quot;,&quot;description&quot;:null,&quot;created_at&quot;:&quot;2021-11-23 03:06:49&quot;,&quot;updated_at&quot;:&quot;2021-11-23 03:06:49&quot;,&quot;pivot&quot;:{&quot;user_id&quot;:1,&quot;role_id&quot;:1}}]
  
  [{&quot;id&quot;:2,&quot;name&quot;:&quot;Moderator&quot;,&quot;description&quot;:null,&quot;created_at&quot;:&quot;2021-11-23 03:06:49&quot;,&quot;updated_at&quot;:&quot;2021-11-23 03:06:49&quot;,&quot;pivot&quot;:{&quot;user_id&quot;:2,&quot;role_id&quot;:2}}]
  </code></pre>
  <p>How can I only display the names in the table role column?</p>