1 | <?php namespace Anomaly\UsersModule\Role; |
||
16 | class RoleRepository extends EntryRepository implements RoleRepositoryInterface |
||
17 | { |
||
18 | |||
19 | /** |
||
20 | * The role model. |
||
21 | * |
||
22 | * @var RoleModel |
||
23 | */ |
||
24 | protected $model; |
||
25 | |||
26 | /** |
||
27 | * Create a new RoleRepositoryInterface instance. |
||
28 | * |
||
29 | * @param RoleModel $model |
||
30 | */ |
||
31 | function __construct(RoleModel $model) |
||
35 | |||
36 | /** |
||
37 | * Return all but the admin role. |
||
38 | * |
||
39 | * @return RoleCollection |
||
40 | */ |
||
41 | public function allButAdmin() |
||
42 | { |
||
43 | return $this->model->where('slug', '!=', 'admin')->get(); |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * Find a role by it's slug. |
||
48 | * |
||
49 | * @param $slug |
||
50 | * @return null|RoleInterface |
||
51 | */ |
||
52 | public function findBySlug($slug) |
||
56 | |||
57 | /** |
||
58 | * Find a role by a permission key. |
||
59 | * |
||
60 | * @param $permission |
||
61 | * @return null|EntryCollection |
||
62 | */ |
||
63 | public function findByPermission($permission) |
||
73 | |||
74 | /** |
||
75 | * Update permissions for a role. |
||
76 | * |
||
77 | * @param RoleInterface $role |
||
78 | * @param array $permissions |
||
79 | * @return RoleInterface |
||
80 | */ |
||
81 | public function updatePermissions(RoleInterface $role, array $permissions) |
||
89 | } |
||
90 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.