messages implemented
This commit is contained in:
@@ -69,15 +69,21 @@ class ArtworkAwardService
|
||||
|
||||
/**
|
||||
* Remove an award for a user/artwork pair.
|
||||
* Uses model-level delete so the ArtworkAwardObserver fires.
|
||||
*/
|
||||
public function removeAward(Artwork $artwork, User $user): void
|
||||
{
|
||||
ArtworkAward::where('artwork_id', $artwork->id)
|
||||
$award = ArtworkAward::where('artwork_id', $artwork->id)
|
||||
->where('user_id', $user->id)
|
||||
->delete();
|
||||
->first();
|
||||
|
||||
$this->recalcStats($artwork->id);
|
||||
$this->syncToSearch($artwork);
|
||||
if ($award) {
|
||||
$award->delete(); // fires ArtworkAwardObserver::deleted
|
||||
} else {
|
||||
// Nothing to remove, but still sync stats to be safe.
|
||||
$this->recalcStats($artwork->id);
|
||||
$this->syncToSearch($artwork);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user