6
votes

I have a role where the user must be 'approved' first, before accessing certain parts of the site. The role ID for 'unapproved' is 5, approved is 2.

Within my admin view, I want to get all users where role ID = 5, to then be able to delete/approve etc...

Currently, my admin controller is:

public function getUnApproved()
{

    $role = Role::find(5)->user()->get();

    $this->layout->content = View::make('admin.manage.approve', 
                                         array('role' => $role));
}

The error message is:

BadMethodCallException Call to undefined method Illuminate\Database\Query\Builder::user()

Entrust is set up correctly, with a Role, Permission model. My user model 'HasRole' also.

Any help would be hugely appreciated.

1

1 Answers

15
votes

By making plural 'user', this solved my problem.

$role = Role::find(5)->users()->get();