'integer', 'parent_id' => 'integer', 'type' => 'integer', 'status' => 'integer', 'sort' => 'integer']; const CREATED_AT = 'create_time'; const UPDATED_AT = 'update_time'; /** * 获取所有 * @return array */ public function getAllMenu(): array { return $this ->where('status', AuthCode::MENU_STATUS_ENABLE) ->orderBy('sort', 'desc') ->get() ->toArray(); } /** * @return array */ public function getAllIds() { return $this ->where('status', AuthCode::MENU_STATUS_ENABLE) ->orderBy('sort', 'desc') ->pluck('id') ->toArray(); } /** * @param $ids * @return array|false */ public function getRoleMenu($ids): array|false { $res = $this ->where('status', AuthCode::MENU_STATUS_ENABLE) ->whereIn('id',$ids) ->orderBy('sort', 'desc') ->get(); if (empty($res)) return false; return $res->toArray(); } /** * @param string $url * @return Builder|\Hyperf\Database\Model\Model|null */ public function getMenuByUrl(string $url): \Hyperf\Database\Model\Model|Builder|null { return $this ->where('url', $url) ->first(); } /** * @param int $id * @return HigherOrderTapProxy|mixed|null */ public function getChildMenuType(int $id): mixed { return $this->where('parent_id', $id)->value('type'); } }