1 <?php namespace BookStack\Uploads;
3 use BookStack\Entities\Models\Page;
5 use BookStack\Traits\HasCreatorAndUpdater;
9 * @property string $name
10 * @property string $url
11 * @property string $path
12 * @property string $type
13 * @property int $uploaded_to
14 * @property int $created_by
15 * @property int $updated_by
17 class Image extends Model
19 use HasCreatorAndUpdater;
21 protected $fillable = ['name'];
22 protected $hidden = [];
25 * Get a thumbnail for this image.
28 public function getThumb(int $width, int $height, bool $keepRatio = false): string
30 return app()->make(ImageService::class)->getThumbnail($this, $width, $height, $keepRatio);
34 * Get the page this image has been uploaded to.
35 * Only applicable to gallery or drawio image types.
37 public function getPage(): ?Page
39 return $this->belongsTo(Page::class, 'uploaded_to')->first();