diff options
Diffstat (limited to 'app/Model/GroupMember.php')
-rw-r--r-- | app/Model/GroupMember.php | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/app/Model/GroupMember.php b/app/Model/GroupMember.php index 7ed5f733..14041704 100644 --- a/app/Model/GroupMember.php +++ b/app/Model/GroupMember.php @@ -108,4 +108,21 @@ class GroupMember extends Base ->eq('user_id', $user_id) ->exists(); } + + /** + * Get all groups for a given user + * + * @access public + * @param integer $user_id + * @return array + */ + public function getGroups($user_id) + { + return $this->db->table(self::TABLE) + ->columns(Group::TABLE.'.id', Group::TABLE.'.name') + ->join(Group::TABLE, 'id', 'group_id') + ->eq(self::TABLE.'.user_id', $user_id) + ->asc(Group::TABLE.'.name') + ->findAll(); + } } |