]> BookStack Code Mirror - bookstack/blobdiff - app/Uploads/Image.php
Move logFailedAccess into Activity
[bookstack] / app / Uploads / Image.php
index df6d9fb0d151ef00cd8c579bdccc3891e3626974..c76979d7cab0c5bee668b3e6a993d781842aa77c 100644 (file)
@@ -1,5 +1,6 @@
 <?php namespace BookStack\Uploads;
 
+use BookStack\Entities\Page;
 use BookStack\Ownable;
 use Images;
 
@@ -7,6 +8,7 @@ class Image extends Ownable
 {
 
     protected $fillable = ['name'];
+    protected $hidden = [];
 
     /**
      * Get a thumbnail for this image.
@@ -20,4 +22,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();
+    }
 }