cacheName_1)) { $list = DB::select("CALL SP_MENU_LIST();"); $rows = count($list); $total = $this->count(); $ret = (object)[ 'total' => $total, 'rows' => $rows, 'list' => $list ]; Cache::put($this->cacheName_1, $ret, $this->cacheTime); } return $ret; } /** * 메뉴 저장 */ public function register(array $insertData): int { $insertData = [ $insertData['menu_id'], $insertData['name'], $insertData['link'], $insertData['target'], $insertData['desktop'], $insertData['mobile'], $insertData['custom'], $insertData['icon'], $insertData['depth'] ]; $menuID = DB::selectOne("CALL SP_MENU_SAVE(?, ?, ?, ?, ?, ?, ?, ?, ?);", $insertData)->id; $this->reload(); return $menuID; } /** * 메뉴 수정 */ public function updater(array $updateData): void { DB::select("CALL SP_MENU_UPDATE(?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", [ $updateData['menu_id'], $updateData['parent_id'], $updateData['name'], $updateData['link'], $updateData['target'], $updateData['desktop'], $updateData['mobile'], $updateData['custom'], $updateData['icon'], $updateData['depth'] ]); $this->reload(); } /** * 메뉴 삭제 */ public function remove(int $menuID): void { DB::select("CALL SP_MENU_DELETE(?);", [$menuID]); $this->reload(); } /** * 메뉴 캐시 생성 */ private function reload(): void { Cache::forget($this->cacheName_1); Cache::forget($this->cacheName_2); $this->data(); } /** * 메뉴 한 단계 위로 */ public function orderUp(int $menuID): void { $this->findCategory($menuID)->up(); $this->reload(); } /** * 메뉴 한 단계 아래로 */ public function orderDown(int $menuID): void { $this->findCategory($menuID)->down(); $this->reload(); } /** * 메뉴 조회 */ public function findCategory(int $menuID): Menu { return (new Menu)->newQuery()->findOrNew($menuID); } }