]> BookStack Code Mirror - bookstack/blobdiff - app/Uploads/Image.php
Add the "Create Shelf" resp. "Create Book" to the home view
[bookstack] / app / Uploads / Image.php
index df6d9fb0d151ef00cd8c579bdccc3891e3626974..6fa5db2a562e703fa0d18aa12b5abb753de0e80b 100644 (file)
@@ -1,5 +1,6 @@
 <?php namespace BookStack\Uploads;
 
+use BookStack\Entities\Page;
 use BookStack\Ownable;
 use Images;
 
@@ -20,4 +21,14 @@ class Image extends Ownable
     {
         return Images::getThumbnail($this, $width, $height, $keepRatio);
     }
+
+    /**
+     * Get the page this image has been uploaded to.
+     * Only applicable to gallery or drawio image types.
+     * @return Page|null
+     */
+    public function getPage()
+    {
+        return $this->belongsTo(Page::class, 'uploaded_to')->first();
+    }
 }