1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-10-13 11:47:56 +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\Console\Commands;
use BookStack\Entities\Models\Bookshelf;
use BookStack\Entities\Queries\BookshelfQueries;
use BookStack\Entities\Tools\PermissionsUpdater;
use Illuminate\Console\Command;
@@ -28,7 +29,7 @@ class CopyShelfPermissionsCommand extends Command
/**
* Execute the console command.
*/
public function handle(PermissionsUpdater $permissionsUpdater): int
public function handle(PermissionsUpdater $permissionsUpdater, BookshelfQueries $queries): int
{
$shelfSlug = $this->option('slug');
$cascadeAll = $this->option('all');
@@ -51,11 +52,11 @@ class CopyShelfPermissionsCommand extends Command
return 0;
}
$shelves = Bookshelf::query()->get(['id']);
$shelves = $queries->start()->get(['id']);
}
if ($shelfSlug) {
$shelves = Bookshelf::query()->where('slug', '=', $shelfSlug)->get(['id']);
$shelves = $queries->start()->where('slug', '=', $shelfSlug)->get(['id']);
if ($shelves->count() === 0) {
$this->info('No shelves found with the given slug.');
}