Add FeaturedArtworkThumbnailGenerator and FeaturedArtworkSelector

This commit is contained in:
2026-05-06 18:54:57 +02:00
parent 2c2c0f6722
commit bd8a5c14a0
2 changed files with 248 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace App\Services\Featured;
use App\Models\Artwork;
use Illuminate\Database\Eloquent\Builder;
final class FeaturedArtworkSelector
{
public function querySelectedArtworks(): Builder
{
return Artwork::query()
->select('artworks.*')
->join('artwork_features as af', 'af.artwork_id', '=', 'artworks.id')
->where('af.is_active', true)
->whereNull('af.deleted_at')
->where(function (Builder $query): void {
$query->whereNull('af.expires_at')
->orWhere('af.expires_at', '>', now());
})
->where('artworks.is_public', true)
->where('artworks.is_approved', true)
->whereNull('artworks.deleted_at')
->whereNotNull('artworks.published_at')
->where('artworks.published_at', '<=', now())
->distinct()
->orderByDesc('artworks.id');
}
}