'title', 'memo' => 'title', 'txt' => 'title', 't' => 'title', ]; public static function _mapField($sField) { if (isset(self::$sFieldNick[$sField])) { return self::$sFieldNick[$sField]; } else { return $sField; } } public static function _no($sPath, $iNo, $iIsDel = 0) { $oSelf = self::where("path", $sPath)->where("no", $iNo)->orderBy("no")->first(); return $oSelf; } public static function _no_arr($sPath, $aNo, $iIsDel = 0) { $oSelf = self::where("path", $sPath)->whereIn("no", $aNo)->orderBy("no")->get(); return $oSelf; } public static function _id_arr($sPath, $aId, $iIsDel = 0) { $oSelf = self::where("path", $sPath)->whereIn("id", $aId)->orderBy("no")->get(); return $oSelf; } public static function _path($sPath, $iPage = 1, $iIsDel = 0) { // 获取上级id if ($sPath == "/") { $iParentId = "1"; } else { $tmp = trim($sPath, "/"); $aPath = explode("/", $tmp); $tmp = count($aPath); $iParentId = $aPath[$tmp-1]; } // 获取上级rag $oParentRag = self::where("id", $iParentId)->first(); // 上级属性 $sOrder = $oParentRag->order ?? "no"; $sOrderType = $oParentRag->order_type ?? "asc"; // 上级option $aRagOption = json_decode($oParentRag->option, 1); if (empty($oParentRag->limit)) { $iLimit = BookOption::_hit("page_limit"); } else { $iLimit = $oParentRag->limit; } $oSelf = self::where("path", $sPath)->where("is_del", $iIsDel); // where if ($iPage !== "all") { // sort覆盖特殊规则 if ($oParentRag->sort) { $aSort = explode("_", $oParentRag->sort); $oSelf = $oSelf->where($aSort[0], $aSort[1]); } else { if (isset($aRagOption["where"])) { $oSelf = $oSelf->whereRaw($aRagOption["where"]); } if ($oParentRag->type == "todo") { $oSelf = $oSelf->where("rank", "!=", "done"); $oSelf = $oSelf->where("rank", "!=", "block"); } } } if ($oParentRag->order == "rank_todo") { $sTodoOrder = BookOption::_hit("order_rank_todo"); $aOrder = explode(",", $sTodoOrder); $oSelf = $oSelf->orderByRaw("rank IS NULL, FIELD(rank, " . $sTodoOrder . ") ".$sOrderType); $oSelf = $oSelf->orderByRaw("fire IS NULL, fire ASC"); $sOrder = "no"; $sOrderType = "asc"; } $oSelf = $oSelf->orderBy($sOrder, $sOrderType); $oSelf = $oSelf->orderBy("updated_at", "desc"); if ($iPage == "all") { $oSelf = $oSelf->get(); } else { $oSelf = $oSelf->paginate($iLimit, ['*'], 'page', $iPage); } return $oSelf; } public static function _noByChecked($sPath, $sType = "no") { $aNo = self::where("path", $sPath)->where("checked", 1)->pluck($sType)->toArray(); return $aNo; } }