use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\BookChild;
-use BookStack\Entities\Models\Bookshelf;
use BookStack\Entities\Models\Chapter;
use BookStack\Entities\Models\Entity;
use BookStack\Entities\Models\Page;
+use BookStack\Entities\Queries\EntityQueries;
use BookStack\Permissions\Models\JointPermission;
use BookStack\Users\Models\Role;
use Illuminate\Database\Eloquent\Builder;
*/
class JointPermissionBuilder
{
+ public function __construct(
+ protected EntityQueries $queries,
+ ) {
+ }
+
+
/**
* Re-generate all entity permission from scratch.
*/
});
// Chunk through all bookshelves
- Bookshelf::query()->withTrashed()->select(['id', 'owned_by'])
+ $this->queries->shelves->start()->withTrashed()->select(['id', 'owned_by'])
->chunk(50, function (EloquentCollection $shelves) use ($roles) {
$this->createManyJointPermissions($shelves->all(), $roles);
});
});
// Chunk through all bookshelves
- Bookshelf::query()->select(['id', 'owned_by'])
+ $this->queries->shelves->start()->select(['id', 'owned_by'])
->chunk(100, function ($shelves) use ($roles) {
$this->createManyJointPermissions($shelves->all(), $roles);
});
*/
protected function bookFetchQuery(): Builder
{
- return Book::query()->withTrashed()
+ return $this->queries->books->start()->withTrashed()
->select(['id', 'owned_by'])->with([
'chapters' => function ($query) {
$query->withTrashed()->select(['id', 'owned_by', 'book_id']);