3 namespace BookStack\Uploads;
5 use BookStack\Entities\Models\Page;
7 use BookStack\Traits\HasCreatorAndUpdater;
8 use Illuminate\Database\Eloquent\Factories\HasFactory;
12 * @property string $name
13 * @property string $url
14 * @property string $path
15 * @property string $type
16 * @property int $uploaded_to
17 * @property int $created_by
18 * @property int $updated_by
20 class Image extends Model
23 use HasCreatorAndUpdater;
25 protected $fillable = ['name'];
26 protected $hidden = [];
29 * Get a thumbnail for this image.
33 public function getThumb(int $width, int $height, bool $keepRatio = false): string
35 return app()->make(ImageService::class)->getThumbnail($this, $width, $height, $keepRatio);
39 * Get the page this image has been uploaded to.
40 * Only applicable to gallery or drawio image types.
42 public function getPage(): ?Page
44 return $this->belongsTo(Page::class, 'uploaded_to')->first();