'create_time', 'id' => 'id']; } /** * @notes 设置默认排序 * @return array * @author heshihu * @date 2022/2/9 15:08 */ public function setDefaultOrder(): array { return ['sort' => 'desc', 'id' => 'desc']; } /** * @notes 获取管理列表 * @return array * @author heshihu * @date 2022/2/21 17:11 */ public function lists(): array { $lists = ArticleCate::where($this->searchWhere) ->append(['is_show_desc', 'article_count']) ->order($this->sortOrder) ->select() ->toArray(); $pid = 0; if (!empty($lists)) { $pid = min(array_column($lists, 'pid')); } return self::getTree($lists, $pid); } public static function getTree($array, $pid = 0) { $list = []; foreach ($array as $item) { if ($item['pid'] == $pid) { $item['children'] = self::getTree($array, $item['id']); $list[] = $item; } } return $list; } /** * @notes 获取数量 * @return int * @author heshihu * @date 2022/2/9 15:12 */ public function count(): int { return ArticleCate::where($this->searchWhere)->count(); } public function extend() { return []; } }