1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-07 23:03:00 +03:00

Queries: Extracted static page,chapter,shelf queries to classes

This commit is contained in:
Dan Brown
2024-02-07 21:58:27 +00:00
parent 483410749b
commit 546cfb0dcc
15 changed files with 93 additions and 60 deletions

View File

@@ -3,6 +3,7 @@
namespace BookStack\Search;
use BookStack\Entities\Models\Page;
use BookStack\Entities\Queries\PageQueries;
use BookStack\Entities\Queries\Popular;
use BookStack\Entities\Tools\SiblingFetcher;
use BookStack\Http\Controller;
@@ -11,7 +12,8 @@ use Illuminate\Http\Request;
class SearchController extends Controller
{
public function __construct(
protected SearchRunner $searchRunner
protected SearchRunner $searchRunner,
protected PageQueries $pageQueries,
) {
}
@@ -95,12 +97,11 @@ class SearchController extends Controller
$searchOptions->setFilter('is_template');
$entities = $this->searchRunner->searchEntities($searchOptions, 'page', 1, 20)['results'];
} else {
$entities = Page::visible()
->where('template', '=', true)
$entities = $this->pageQueries->visibleTemplates()
->where('draft', '=', false)
->orderBy('updated_at', 'desc')
->take(20)
->get(Page::$listAttributes);
->get();
}
return view('search.parts.entity-selector-list', [