updated gallery

This commit is contained in:
2026-03-17 18:34:26 +01:00
parent 7b37259a2c
commit 7da0fd39f7
52 changed files with 1216 additions and 870 deletions

View File

@@ -276,7 +276,7 @@ class ArtworkService
$q->where('af.type', $type);
})
->with([
'user:id,name',
'user:id,name,username',
'categories' => function ($q) {
$q->select('categories.id', 'categories.content_type_id', 'categories.parent_id', 'categories.name', 'categories.slug', 'categories.sort_order');
},

View File

@@ -254,8 +254,25 @@ final class TagService
public function updateUsageCount(Tag $tag): void
{
$this->syncUsageCount($tag);
}
/**
* Recalculate and persist the real usage_count from artwork_tag.
*
* @return array{before:int, after:int, changed:bool}
*/
public function syncUsageCount(Tag $tag): array
{
$before = (int) $tag->usage_count;
$count = (int) DB::table('artwork_tag')->where('tag_id', $tag->id)->count();
$tag->forceFill(['usage_count' => $count])->save();
return [
'before' => $before,
'after' => $count,
'changed' => $before !== $count,
];
}
/**