title: Creating separate tables dependant on user roles
body: <p>I have created a table called 'users' and within this table users can have one of three roles. I am trying to create three separate tables to group the different users within the one page, or a separate page, according to their role. At the moment I have them displaying in one table.</p>
  
  <p>User index.blade.php </p>
  
  <pre><code>@extends('layouts.app')
  @section('content')
  
  &lt;div class="container"&gt;
          &lt;div class="row justify-content-center"&gt;
                  &lt;div class="col-md-10"&gt;
                      &lt;p&gt;
                          &lt;a href="{{ route('admin.users.create') }}"&gt;&lt;button type="button" class="btn btn-success"&gt;Create User&lt;/button&gt;&lt;/a&gt;
                      &lt;/p&gt;
  
                      &lt;div class="card"&gt;
                              &lt;div class="card-header"&gt;Manage Users&lt;/div&gt;
                              &lt;div class="card-body"&gt;
                              &lt;div class="table-responsive"&gt; 
                                  &lt;table class="table"&gt;
                                      &lt;thead&gt;
                                      &lt;tr&gt;
                                          &lt;th&gt;ID&lt;/th&gt;
                                          &lt;th&gt;Name&lt;/th&gt;
                                          &lt;th&gt;Course&lt;/th&gt;
                                          &lt;th&gt;Role&lt;/th&gt; 
                                          &lt;th&gt;&lt;/th&gt;
                                          &lt;th&gt;&lt;/th&gt;
                                          &lt;th&gt;&lt;/th&gt;
                                      &lt;/tr&gt;
                                      &lt;/thead&gt;
                                      &lt;tbody&gt;
                                      @foreach ($users as $user)
                                          &lt;tr&gt;
                                              &lt;th scope="row"&gt;{{ $user-&gt;id }}&lt;/th&gt;
                                              &lt;td&gt;{{ $user-&gt;name}}&lt;/td&gt;
                                              &lt;td&gt;{{ implode ($user-&gt;courses()-&gt;pluck('title')-&gt;toArray()) }}&lt;/td&gt;
                                              &lt;td&gt;{{ implode (', ', $user-&gt;roles()-&gt;pluck('role_name')-&gt;toArray()) }}&lt;/td&gt;
                                              &lt;td&gt;
                                                  @can('edit_users')
                                                  &lt;a class="btn btn-xs btn-secondary" href="{{ route('admin.users.show', $user-&gt;id) }}"&gt;
                                                      View
                                                  &lt;/a&gt;
                                                  @endcan
                                              &lt;/td&gt;
                                              &lt;td&gt;    
                                                  @can('edit_users')
                                                  &lt;a class="btn btn-xs btn-primary" href="{{ route('admin.users.edit', $user-&gt;id) }}"&gt;
                                                      Edit
                                                  &lt;/a&gt;
                                                  @endcan
                                              &lt;/td&gt;
                                              &lt;td&gt;
                                                  @can('delete_users')
                                                  &lt;form action="{{ route('admin.users.destroy', $user-&gt;id) }}" method="POST" onsubmit="return confirm('Confirm delete?');" style="display: inline-block;"&gt;
                                                      &lt;input type="hidden" name="_method" value="DELETE"&gt;
                                                      &lt;input type="hidden" name="_token" value="{{ csrf_token() }}"&gt;
                                                      &lt;input type="submit" class="btn btn-xs btn-danger" value="Delete"&gt;
                                                  @endcan
                                              &lt;/form&gt;
                                              &lt;/td&gt; 
                                              &lt;/tr&gt;
                                          @endforeach
                                      &lt;/tbody&gt;
                                      &lt;/table&gt; 
                                      &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                  &lt;/div&gt;
          &lt;/div&gt;
  &lt;/div&gt;
  @endsection
  </code></pre>
  
  <p>I appreciate any help on how I could go about doing this.</p>
  
  <p><a href="https://i.stack.imgur.com/jWfIn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jWfIn.png" alt="enter image description here"></a></p>