false, 'isProcessing' => true, 'lightboxWidth' => 0, 'lightboxHeight' => 0, ]; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = ['album_id', 'lightboxWidth', 'lightboxHeight', 'isCover', 'isProcessing']; public function album(): BelongsTo { return $this->belongsTo(Album::class); } public function getThumbnail() : string { return route('image.thumbnail', $this) . '?cacheBuster3000=' . $this->updated_at->timestamp; } public function getDownload() : string { return route('image.download', $this) . '?cacheBuster3000=' . $this->updated_at->timestamp; } public function setLightboxSize(int $width, int $height) : void { $this->lightboxWidth = $width; $this->lightboxHeight = $height; $this->save(); } public function makeCover() : void { Image::where('isCover', 1)->where('album_id', $this->album_id)->update(['isCover' => 0]); $this->isCover = true; $this->save(); } public function getLightboxAttribute() : array { return [ 'location' => route('image.lightbox', $this) . '?cacheBuster3000=' . $this->updated_at->timestamp, 'width' => $this->lightboxWidth, 'height' => $this->lightboxHeight, ]; } }