change category basic

This commit is contained in:
xiaomlove
2025-09-11 20:08:43 +07:00
parent 58075c37a5
commit 4c46f376ba
5 changed files with 58 additions and 15 deletions

View File

@@ -243,18 +243,20 @@ class SearchBoxRepository extends BaseRepository
return Category::query()->whereIn('id', $idArr)->delete();
}
public function listSections()
public function listSections($withCategoryAndTags = true)
{
$modeIds = [SearchBox::getBrowseMode()];
if (SearchBox::isSpecialEnabled() && Permission::canUploadToSpecialSection()) {
$modeIds[] = SearchBox::getSpecialMode();
}
$searchBoxList = SearchBox::query()->with("categories")->find($modeIds);
foreach ($searchBoxList as $searchBox) {
if ($searchBox->showsubcat) {
$searchBox->loadSubCategories();
$searchBoxList = SearchBox::query()->with($withCategoryAndTags ? ['categories'] : [])->find($modeIds);
if ($withCategoryAndTags) {
foreach ($searchBoxList as $searchBox) {
if ($searchBox->showsubcat) {
$searchBox->loadSubCategories();
}
$searchBox->loadTags();
}
$searchBox->loadTags();
}
return $searchBoxList;
}