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" => SUCCESS, "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; // } $row = $this->where("id", $id)->where("is_del", false)->update(["is_del" => true]); if ($row == 0) { return INVALID_GROUP_ID; } return SUCCESS; } /** * @param $ownerType * @param $ownerId * @return array */ public function ListActionBarIds($ownerType, $ownerId) { $opera = $this->select("bar_id"); if ($ownerType != "") { $opera = $opera->where("owner_type", $ownerType); } $bars = $opera->where("owner_id", $ownerId)->where("status", "normal")->where("is_del", false)->get(); if (count($bars) == 0) { return []; } $bar_ids = []; foreach ($bars as $bar) { array_push($bar_ids, $bar["bar_id"]); } Log::debug("========" . json_encode($bar_ids)); return $bar_ids; } }