]> BookStack Code Mirror - bookstack/blob - app/Uploads/Image.php
Adding Croatian translation files
[bookstack] / app / Uploads / Image.php
1 <?php namespace BookStack\Uploads;
2
3 use BookStack\Entities\Models\Page;
4 use BookStack\Model;
5 use BookStack\Traits\HasCreatorAndUpdater;
6
7 class Image extends Model
8 {
9     use HasCreatorAndUpdater;
10
11     protected $fillable = ['name'];
12     protected $hidden = [];
13
14     /**
15      * Get a thumbnail for this image.
16      * @throws \Exception
17      */
18     public function getThumb(int $width, int $height, bool $keepRatio = false): string
19     {
20         return app()->make(ImageService::class)->getThumbnail($this, $width, $height, $keepRatio);
21     }
22
23     /**
24      * Get the page this image has been uploaded to.
25      * Only applicable to gallery or drawio image types.
26      */
27     public function getPage(): ?Page
28     {
29         return $this->belongsTo(Page::class, 'uploaded_to')->first();
30     }
31 }