This commit is contained in:
2024-06-07 16:26:15 +02:00
parent d01c7d3868
commit 154e79aacd
11 changed files with 153 additions and 29 deletions

View File

@@ -18,6 +18,8 @@ class Image extends Model implements HasThumbnail
*/
protected $attributes = [
'isCover' => false,
'lightboxWidth' => 0,
'lightboxHeight' => 0,
];
/**
@@ -25,7 +27,7 @@ class Image extends Model implements HasThumbnail
*
* @var array
*/
protected $fillable = ['album_id'];
protected $fillable = ['album_id', 'lightboxWidth', 'lightboxHeight'];
public function album(): BelongsTo
{
@@ -33,6 +35,24 @@ class Image extends Model implements HasThumbnail
}
public function getThumbnail() : string {
return route('image.show', $this);
return route('image.thumbnail', $this);
}
public function getDownload() : string {
return route('image.download', $this);
}
public function setLightboxSize(int $width, int $height) : void {
$this->lightboxWidth = $width;
$this->lightboxHeight = $height;
$this->save();
}
public function getLightboxAttribute() : array {
return [
'location' => route('image.lightbox', $this),
'width' => $this->lightboxWidth,
'height' => $this->lightboxHeight,
];
}
}