feat: ship creator journey v2 and profile updates
This commit is contained in:
@@ -653,19 +653,26 @@ class Collection extends Model
|
||||
return $this->isPubliclyAccessible();
|
||||
}
|
||||
|
||||
public function resolvedCoverArtwork(bool $publicOnly = false): ?Artwork
|
||||
public function resolvedCoverArtwork(bool $publicOnly = false, bool $hideMature = false): ?Artwork
|
||||
{
|
||||
$cover = $this->relationLoaded('coverArtwork') ? $this->coverArtwork : $this->coverArtwork()->first();
|
||||
if ($cover && (! $publicOnly || $this->artworkIsPubliclyVisible($cover))) {
|
||||
if ($cover && $this->artworkMatchesCoverVisibility($cover, $publicOnly, $hideMature)) {
|
||||
return $cover;
|
||||
}
|
||||
|
||||
$relation = $publicOnly ? 'publicArtworks' : 'artworks';
|
||||
$artworks = $this->relationLoaded($relation)
|
||||
? $this->getRelation($relation)
|
||||
: $this->{$relation}()->limit(1)->get();
|
||||
: $this->{$relation}()
|
||||
->when($hideMature, function ($query): void {
|
||||
$query->whereRaw('COALESCE(artworks.is_mature, 0) = 0')
|
||||
->whereRaw("COALESCE(artworks.maturity_status, 'clear') != ?", ['suspected']);
|
||||
})
|
||||
->limit(1)
|
||||
->get();
|
||||
|
||||
return $artworks->first();
|
||||
return $artworks
|
||||
->first(fn (Artwork $artwork): bool => $this->artworkMatchesCoverVisibility($artwork, $publicOnly, $hideMature));
|
||||
}
|
||||
|
||||
public function syncArtworksCount(): void
|
||||
@@ -712,4 +719,18 @@ class Collection extends Model
|
||||
&& $artwork->published_at !== null
|
||||
&& $artwork->published_at->lte(now());
|
||||
}
|
||||
|
||||
private function artworkMatchesCoverVisibility(Artwork $artwork, bool $publicOnly, bool $hideMature): bool
|
||||
{
|
||||
if ($publicOnly && ! $this->artworkIsPubliclyVisible($artwork)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! $hideMature) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return ! (bool) $artwork->is_mature
|
||||
&& (string) ($artwork->maturity_status ?? 'clear') !== 'suspected';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user