WIP
This commit is contained in:
@@ -28,6 +28,14 @@ class Album extends Model
|
||||
return $this->images;
|
||||
}
|
||||
|
||||
public function getHasCoverAttribute() : bool {
|
||||
return $this->images()->where('isCover', 1)->count() > 0;
|
||||
}
|
||||
|
||||
public function getHasProcessingMediaAttribute() : bool {
|
||||
return $this->images()->where('isProcessing', 1)->count() > 0;
|
||||
}
|
||||
|
||||
public function getThumbnailAttribute() : ?string {
|
||||
return $this->images()->where('isCover', 1)->first()?->getThumbnail();
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ class Image extends Model implements HasThumbnail
|
||||
*/
|
||||
protected $attributes = [
|
||||
'isCover' => false,
|
||||
'isProcessing' => true,
|
||||
'lightboxWidth' => 0,
|
||||
'lightboxHeight' => 0,
|
||||
];
|
||||
@@ -27,7 +28,7 @@ class Image extends Model implements HasThumbnail
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['album_id', 'lightboxWidth', 'lightboxHeight'];
|
||||
protected $fillable = ['album_id', 'lightboxWidth', 'lightboxHeight', 'isCover', 'isProcessing'];
|
||||
|
||||
public function album(): BelongsTo
|
||||
{
|
||||
@@ -35,11 +36,11 @@ class Image extends Model implements HasThumbnail
|
||||
}
|
||||
|
||||
public function getThumbnail() : string {
|
||||
return route('image.thumbnail', $this);
|
||||
return route('image.thumbnail', $this) . '?cacheBuster3000=' . $this->updated_at->timestamp;
|
||||
}
|
||||
|
||||
public function getDownload() : string {
|
||||
return route('image.download', $this);
|
||||
return route('image.download', $this) . '?cacheBuster3000=' . $this->updated_at->timestamp;
|
||||
}
|
||||
|
||||
public function setLightboxSize(int $width, int $height) : void {
|
||||
@@ -50,7 +51,7 @@ class Image extends Model implements HasThumbnail
|
||||
|
||||
public function getLightboxAttribute() : array {
|
||||
return [
|
||||
'location' => route('image.lightbox', $this),
|
||||
'location' => route('image.lightbox', $this) . '?cacheBuster3000=' . $this->updated_at->timestamp,
|
||||
'width' => $this->lightboxWidth,
|
||||
'height' => $this->lightboxHeight,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user