API: upload sections list

This commit is contained in:
xiaomlove
2025-02-15 03:15:45 +08:00
parent 0d7cbcde9f
commit c9b2237efd
16 changed files with 262 additions and 10 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Repositories;
use App\Auth\Permission;
use App\Exceptions\InsufficientPermissionException;
use App\Http\Middleware\Locale;
use App\Models\Category;
@@ -242,5 +243,20 @@ class SearchBoxRepository extends BaseRepository
return Category::query()->whereIn('id', $idArr)->delete();
}
public function listSections()
{
$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();
}
}
return $searchBoxList;
}
}