EMPTY_OWNER_TYPE]; } if ($ownerId == "") { return ["code" => EMPTY_OWNER_ID]; } if ($barId == "") { return ["code" => EMPTY_BAR_ID]; } // check owner and barId if exist in system. $code = $this->checkOwner($ownerType, $ownerId); if ($code != 0) { return ["code" => $code]; } $code = $this->checkActionBar($barId); if ($code != 0) { return ["code" => $code]; } $result = $this->firstOrCreate(["owner_type" => $ownerType, "owner_id" => $ownerId, "bar_id" => $barId, "is_del" => false]); unset($result["is_del"]); unset($result["created_user_id"]); unset($result["updated_user_id"]); return ["code" => 0, "data" => $result]; } private function checkActionBar($barId) { return SUCCESS; } private function checkOwner($ownerType, $ownerId) { return SUCCESS; } public function RemoveUserActionBar($id) { if ($id < 1) { return INVALID_U_A_ID; } // check the data if exist in system. $item = $this->where("id", $id)->where("is_del", false)->first(); if (!$item) { return INVALID_U_A_ID; } $this->where("id", $id)->where("is_del", false)->update(["is_del" => true]); return SUCCESS; } /** * @param $uid * @return array */ public function ListActionBarIds($uid) { $bars = $this->select("bar_id") ->where("user_id", $uid) ->where("status", "normal") ->where("is_del", false) ->get(); if (count($bars) == 0) { return []; } $bar_ids = []; foreach ($bar_ids as $bar_id) { array_push($bar_ids, $bar_id->bar_id); } return $bar_ids; } }