namespace BookStack\Console\Commands;
use BookStack\Entities\Models\Bookshelf;
-use BookStack\Entities\Repos\BookshelfRepo;
+use BookStack\Entities\Tools\PermissionsUpdater;
use Illuminate\Console\Command;
class CopyShelfPermissions extends Command
*/
protected $description = 'Copy shelf permissions to all child books';
- /**
- * @var BookshelfRepo
- */
- protected $bookshelfRepo;
+ protected PermissionsUpdater $permissionsUpdater;
/**
* Create a new command instance.
*
* @return void
*/
- public function __construct(BookshelfRepo $repo)
+ public function __construct(PermissionsUpdater $permissionsUpdater)
{
- $this->bookshelfRepo = $repo;
+ $this->permissionsUpdater = $permissionsUpdater;
parent::__construct();
}
return;
}
- $shelves = Bookshelf::query()->get(['id', 'restricted']);
+ $shelves = Bookshelf::query()->get(['id']);
}
if ($shelfSlug) {
- $shelves = Bookshelf::query()->where('slug', '=', $shelfSlug)->get(['id', 'restricted']);
+ $shelves = Bookshelf::query()->where('slug', '=', $shelfSlug)->get(['id']);
if ($shelves->count() === 0) {
$this->info('No shelves found with the given slug.');
}
}
foreach ($shelves as $shelf) {
- $this->bookshelfRepo->copyDownPermissions($shelf, false);
+ $this->permissionsUpdater->updateBookPermissionsFromShelf($shelf, false);
$this->info('Copied permissions for shelf [' . $shelf->id . ']');
}