Add FeaturedArtworkThumbnailGenerator and FeaturedArtworkSelector
This commit is contained in:
31
app/Services/Featured/FeaturedArtworkSelector.php
Normal file
31
app/Services/Featured/FeaturedArtworkSelector.php
Normal 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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user