use BookStack\Uploads\AttachmentService;
use BookStack\Uploads\ImageService;
use Exception;
+use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Carbon;
class TrashCan
{
$count = 0;
$pages = $chapter->pages()->withTrashed()->get();
- if (count($pages)) {
- foreach ($pages as $page) {
- $this->destroyPage($page);
- $count++;
- }
+ foreach ($pages as $page) {
+ $this->destroyPage($page);
+ $count++;
}
$this->destroyCommonRelations($chapter);
{
$counts = [];
- /** @var Entity $instance */
foreach ((new EntityProvider())->all() as $key => $instance) {
- $counts[$key] = $instance->newQuery()->onlyTrashed()->count();
+ /** @var Builder<Entity> $query */
+ $query = $instance->newQuery();
+ $counts[$key] = $query->onlyTrashed()->count();
}
return $counts;
$entity->deletions()->delete();
$entity->favourites()->delete();
- if ($entity instanceof HasCoverImage && $entity->cover) {
+ if ($entity instanceof HasCoverImage && $entity->cover()->exists()) {
$imageService = app()->make(ImageService::class);
- $imageService->destroy($entity->cover);
+ $imageService->destroy($entity->cover()->first());
}
}
}