<?php namespace BookStack\Entities\Tools;
-use BookStack\Entities\Book;
-use BookStack\Entities\Bookshelf;
-use BookStack\Entities\Chapter;
-use BookStack\Entities\Deletion;
-use BookStack\Entities\Entity;
+use BookStack\Entities\Models\Book;
+use BookStack\Entities\Models\Bookshelf;
+use BookStack\Entities\Models\Chapter;
+use BookStack\Entities\Models\Deletion;
+use BookStack\Entities\Models\Entity;
use BookStack\Entities\EntityProvider;
-use BookStack\Entities\HasCoverImage;
-use BookStack\Entities\Page;
+use BookStack\Entities\Models\HasCoverImage;
+use BookStack\Entities\Models\Page;
use BookStack\Exceptions\NotifyException;
use BookStack\Facades\Activity;
use BookStack\Uploads\AttachmentService;
*/
public function getTrashedCounts(): array
{
- $provider = app(EntityProvider::class);
$counts = [];
/** @var Entity $instance */
- foreach ($provider->all() as $key => $instance) {
+ foreach ((new EntityProvider)->all() as $key => $instance) {
$counts[$key] = $instance->newQuery()->onlyTrashed()->count();
}
$count++;
};
- if ($entity->isA('chapter') || $entity->isA('book')) {
+ if ($entity instanceof Chapter || $entity instanceof Book) {
$entity->pages()->withTrashed()->withCount('deletions')->get()->each($restoreAction);
}
- if ($entity->isA('book')) {
+ if ($entity instanceof Book) {
$entity->chapters()->withTrashed()->withCount('deletions')->get()->each($restoreAction);
}
/**
* Destroy the given entity.
+ * @throws Exception
*/
protected function destroyEntity(Entity $entity): int
{
- if ($entity->isA('page')) {
+ if ($entity instanceof Page) {
return $this->destroyPage($entity);
}
- if ($entity->isA('chapter')) {
+ if ($entity instanceof Chapter) {
return $this->destroyChapter($entity);
}
- if ($entity->isA('book')) {
+ if ($entity instanceof Book) {
return $this->destroyBook($entity);
}
- if ($entity->isA('shelf')) {
+ if ($entity instanceof Bookshelf) {
return $this->destroyShelf($entity);
}
}