]> BookStack Code Mirror - bookstack/blobdiff - app/Entities/Tools/TrashCan.php
Layout: Converted tri-layout component to ts
[bookstack] / app / Entities / Tools / TrashCan.php
index b0c452456a06d541a97c7e301ed1d7d74b91ef13..39c982cdc92a25219b0df21bfaadac9c4b52a372 100644 (file)
@@ -10,6 +10,7 @@ use BookStack\Entities\Models\Deletion;
 use BookStack\Entities\Models\Entity;
 use BookStack\Entities\Models\HasCoverImage;
 use BookStack\Entities\Models\Page;
+use BookStack\Entities\Queries\EntityQueries;
 use BookStack\Exceptions\NotifyException;
 use BookStack\Facades\Activity;
 use BookStack\Uploads\AttachmentService;
@@ -20,6 +21,11 @@ use Illuminate\Support\Carbon;
 
 class TrashCan
 {
+    public function __construct(
+        protected EntityQueries $queries,
+    ) {
+    }
+
     /**
      * Send a shelf to the recycle bin.
      *
@@ -203,8 +209,14 @@ class TrashCan
         }
 
         // Remove book template usages
-        Book::query()->where('default_template', '=', $page->id)
-            ->update(['default_template' => null]);
+        $this->queries->books->start()
+            ->where('default_template_id', '=', $page->id)
+            ->update(['default_template_id' => null]);
+
+        // Remove chapter template usages
+        $this->queries->chapters->start()
+            ->where('default_template_id', '=', $page->id)
+            ->update(['default_template_id' => null]);
 
         $page->forceDelete();