]> BookStack Code Mirror - bookstack/blobdiff - app/Uploads/Image.php
Show tags of all search results
[bookstack] / app / Uploads / Image.php
index df6d9fb0d151ef00cd8c579bdccc3891e3626974..dc26af002ab5e29de70d3679d9a56282b39bb458 100644 (file)
@@ -1,12 +1,16 @@
 <?php namespace BookStack\Uploads;
 
-use BookStack\Ownable;
+use BookStack\Entities\Models\Page;
+use BookStack\Model;
+use BookStack\Traits\HasCreatorAndUpdater;
 use Images;
 
-class Image extends Ownable
+class Image extends Model
 {
+    use HasCreatorAndUpdater;
 
     protected $fillable = ['name'];
+    protected $hidden = [];
 
     /**
      * Get a thumbnail for this image.
@@ -20,4 +24,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();
+    }
 }