Save workspace changes

This commit is contained in:
2026-04-18 17:02:56 +02:00
parent f02ea9a711
commit 87d60af5a9
4220 changed files with 1388603 additions and 1554 deletions

View File

@@ -0,0 +1,59 @@
<?php
declare(strict_types=1);
namespace App\Services;
use App\Models\Artwork;
use App\Models\ArtworkAward;
use App\Models\ArtworkAwardStat;
use App\Models\User;
class ArtworkAwardService
{
public function __construct(private readonly ArtworkMedalService $medals)
{
}
/**
* Award an artwork with the given medal.
* Throws ValidationException if the user already awarded this artwork.
*/
public function award(Artwork $artwork, User $user, string $medal): ArtworkAward
{
return $this->medals->award($artwork, $user, $medal);
}
/**
* Change an existing award medal for a user/artwork pair.
*/
public function changeAward(Artwork $artwork, User $user, string $medal): ArtworkAward
{
return $this->medals->changeMedal($artwork, $user, $medal);
}
/**
* Remove an award for a user/artwork pair.
* Uses model-level delete so the ArtworkAwardObserver fires.
*/
public function removeAward(Artwork $artwork, User $user): void
{
$this->medals->removeMedal($artwork, $user);
}
/**
* Recalculate and persist stats for the given artwork.
*/
public function recalcStats(int $artworkId): ArtworkAwardStat
{
return $this->medals->recalculateStats($artworkId);
}
/**
* Queue a non-blocking reindex for the artwork after award stats change.
*/
public function syncToSearch(Artwork $artwork): void
{
$this->medals->syncArtworkToSearch((int) $artwork->id);
}
}