Skip to content

Commit

Permalink
fixes 1608 (#1609)
Browse files Browse the repository at this point in the history
  • Loading branch information
ildyria authored Nov 28, 2022
1 parent 7b8eaed commit a328ccd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/Models/Extensions/Thumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static function createFromQueryable(Relation|Builder $photoQueryable, Sor
try {
/** @var Photo|null $cover */
$cover = $photoQueryable
->withOnly(['size_variants' => fn (HasMany $r) => self::sizeVariantsFilter($r)])
->withOnly(['size_variants' => (fn (HasMany $r) => self::sizeVariantsFilter($r))])
->orderBy('photos.' . PhotoSortingCriterion::COLUMN_IS_STARRED, SortingCriterion::DESC)
->orderBy('photos.' . $sorting->column, $sorting->order)
->select(['photos.id', 'photos.type'])
Expand Down
7 changes: 7 additions & 0 deletions app/Models/Photo.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ class Photo extends Model implements HasRandomID
'is_share_button_visible',
];

/**
* @var array<int,string> By default preload all the size_variants
*/
protected $with = [
'size_variants',
];

/**
* Creates a new instance of {@link LinkedPhotoCollection}.
*
Expand Down
2 changes: 1 addition & 1 deletion app/Relations/HasAlbumThumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(Album $parent)
$this->photoQueryPolicy = resolve(PhotoQueryPolicy::class);
$this->sorting = PhotoSortingCriterion::createDefault();
parent::__construct(
Photo::query()->with(['size_variants' => fn (HasMany $r) => Thumb::sizeVariantsFilter($r)]),
Photo::query()->with(['size_variants' => (fn (HasMany $r) => Thumb::sizeVariantsFilter($r))]),
$parent
);
}
Expand Down

0 comments on commit a328ccd

Please sign in to comment.