minor fixes

This commit is contained in:
2026-04-09 08:50:36 +02:00
parent 23d363a50c
commit a2457f4e49
75 changed files with 3848 additions and 387 deletions

View File

@@ -23,6 +23,24 @@ class ArtworkService
{
protected int $cacheTtl = 3600; // seconds
/**
* Lightweight relations needed to render browse/list cards.
*
* @return array<int|string, mixed>
*/
private function browseRelations(): array
{
return [
'user:id,name,username',
'user.profile:user_id,avatar_url',
'group:id,name,slug,avatar_path',
'categories' => function ($q) {
$q->select('categories.id', 'categories.content_type_id', 'categories.parent_id', 'categories.name', 'categories.slug', 'categories.sort_order')
->with(['parent:id,parent_id,content_type_id,name,slug', 'contentType:id,slug,name']);
},
];
}
/**
* Shared browse query used by /browse, content-type pages, and category pages.
*/
@@ -30,13 +48,7 @@ class ArtworkService
{
$query = Artwork::public()
->published()
->with([
'user:id,name',
'categories' => function ($q) {
$q->select('categories.id', 'categories.content_type_id', 'categories.parent_id', 'categories.name', 'categories.slug', 'categories.sort_order')
->with(['parent:id,parent_id,content_type_id,name,slug', 'contentType:id,slug,name']);
},
]);
->with($this->browseRelations());
$normalizedSort = strtolower(trim($sort));
if ($normalizedSort === 'oldest') {
@@ -110,6 +122,7 @@ class ArtworkService
public function getCategoryArtworks(Category $category, int $perPage = 24): CursorPaginator
{
$query = Artwork::public()->published()
->with($this->browseRelations())
->whereHas('categories', function ($q) use ($category) {
$q->where('categories.id', $category->id);
})