6
0
Fork 0

文章分类

release
panliang 2022-05-31 10:06:15 +08:00
parent 53f8327a94
commit 517e96e8a7
1 changed files with 3 additions and 2 deletions

View File

@ -17,6 +17,7 @@ use Illuminate\Http\Request;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Throwable; use Throwable;
use Dcat\Admin\Support\Helper;
class ArticleController extends Controller class ArticleController extends Controller
{ {
@ -64,8 +65,8 @@ class ArticleController extends Controller
public function categoryTree() public function categoryTree()
{ {
$nodes = ArticleCategory::select(['id', 'cover', 'name', 'parent_id', 'sort'])->get(); $nodes = ArticleCategory::where('parent_id', 3)->where('is_show', 1)->select(['id', 'cover', 'name', 'parent_id', 'sort'])->get();
$list = (new ArticleCategory())->toTree($nodes->all()); $list = Helper::buildNestedArray($nodes->all(), 3, 'id', 'parent_id');
return $list; return $list;
} }