Laravel选择用户角色和功能并列出它们

I want to ge the role per user and display them inside an table.

What I want as output is something like this:

output

So the table head Functie needs to be the function name of my database table column name inside table roles.

My controller:

public function index()
    {

        $select_all_users = DB::table('users')->orderBy('username', 'DESC')->get();

        foreach ($select_all_users as $users) {

            //make an array object of the news
            $users = array();

            $select_user_role = DB::table('users')
            ->join('roles', 'users.role_id', '=', 'roles.id')
            ->select('roles.id', 'roles.name', 'roles.description', 'roles.color')
            ->where('username', '=', Auth::user()->username)
            ->first();
        }



        return View::make('admin.users.index')->with('select_user', $select_all_users);
    }

I know that the $select_user_role only will take the value of the users session...

So now I want them listed per user.

My view:

<tbody>

                            @foreach($select_user as $user)

                            <td>{{ ucfirst($user->username) }}</td>

                            <td>{{ ucfirst($user->last_name) }}</td>

                            <td>{{ $user->email }}</td>

                            <td>Here needs to come the role name</td>

                            <td>{{ $user->status }}</td>

                            <td>{{ strftime('%A %d %B %Y', $user->registered_at) }}</td>

                            <td>{{ strftime('%A %d %B %Y', $user->last_login) }}</td>

                            <td><a href="{{ URL::to('admin/user/' . $user->id . '/edit') }}" class="btn btn-sm yellow">Bewerk <i class="fa fa-edit"></i></a></td>

                            <td>
                            {{ Form::open(['method' => 'delete',  'route' => ['admin.user.destroy', $user->id]]) }}
                                {{ Form::button('Verwijderen <i class="fa fa-user-times"></i>', array('type' => 'submit', 'class' => 'btn btn-sm red')) }}
                            {{ Form::close() }}

                            </td>

                            </tr>
                            @endforeach

                            </tbody>

First: add a relation to your user model:

class User extends Model {

    // ...

    public function role()
    {
        return $this->belongsTo('App\Role'); // apply your namespace accordingly
    }
}

Then, within your controller, use eager loading to get all the users with their roles:

public function index()
{
    $select_all_users = User::with('role')->get();

    return View::make('admin.users.index')->with('select_user', $select_all_users);
}