select("group_id")->where("user_id", $uid)->where("is_del", false)->all(); $group_ids = []; foreach ($groups as $group) { array_push($group_ids, $group->group_id); } return $group_ids; } public function GroupAddUser($gid, $uid) { if ($gid == "") { return ["code" => EMPTY_GROUP_ID]; } if ($uid == "") { return ["code" => EMPTY_USER_ID]; } $result = $this->firstOrCreate(["group_id" => $gid, "user_id" => $uid, "is_del" => false]); unset($result["is_del"]); unset($result["created_user_id"]); unset($result["updated_user_id"]); return ["code" => SUCCESS, "data" => $result]; } public function GroupRemoveUser($id) { if ($id < 1) { return INVALID_GROUP_USER_ID; } $row = $this->where("id", $id)->where("is_del", false)->update(["is_del" => true]); if ($row == 0) { return INVALID_GROUP_USER_ID; } return SUCCESS; } }