feat: merge Like+Favourite into single heart button, add Report modal with required reason & proof, fix favourite 422 (user_favorites -> artwork_favourites)

This commit is contained in:
2026-02-28 15:15:37 +01:00
parent eee7df1f8c
commit 568b3f3abb
2 changed files with 185 additions and 71 deletions

View File

@@ -20,11 +20,11 @@ final class ArtworkInteractionController extends Controller
$this->toggleSimple(
request: $request,
table: 'user_favorites',
table: 'artwork_favourites',
keyColumns: ['user_id', 'artwork_id'],
keyValues: ['user_id' => (int) $request->user()->id, 'artwork_id' => $artworkId],
insertPayload: ['created_at' => now()],
requiredTable: 'user_favorites'
insertPayload: ['created_at' => now(), 'updated_at' => now()],
requiredTable: 'artwork_favourites'
);
$this->syncArtworkStats($artworkId);
@@ -154,8 +154,8 @@ final class ArtworkInteractionController extends Controller
return;
}
$favorites = Schema::hasTable('user_favorites')
? (int) DB::table('user_favorites')->where('artwork_id', $artworkId)->count()
$favorites = Schema::hasTable('artwork_favourites')
? (int) DB::table('artwork_favourites')->where('artwork_id', $artworkId)->count()
: 0;
$likes = Schema::hasTable('artwork_likes')
@@ -167,23 +167,22 @@ final class ArtworkInteractionController extends Controller
[
'favorites' => $favorites,
'rating_count' => $likes,
'updated_at' => now(),
]
);
}
private function statusPayload(int $viewerId, int $artworkId): array
{
$isFavorited = Schema::hasTable('user_favorites')
? DB::table('user_favorites')->where('user_id', $viewerId)->where('artwork_id', $artworkId)->exists()
$isFavorited = Schema::hasTable('artwork_favourites')
? DB::table('artwork_favourites')->where('user_id', $viewerId)->where('artwork_id', $artworkId)->exists()
: false;
$isLiked = Schema::hasTable('artwork_likes')
? DB::table('artwork_likes')->where('user_id', $viewerId)->where('artwork_id', $artworkId)->exists()
: false;
$favorites = Schema::hasTable('user_favorites')
? (int) DB::table('user_favorites')->where('artwork_id', $artworkId)->count()
$favorites = Schema::hasTable('artwork_favourites')
? (int) DB::table('artwork_favourites')->where('artwork_id', $artworkId)->count()
: 0;
$likes = Schema::hasTable('artwork_likes')