Add Album Endpoint Eklendi
25 Aralık 2025
Eksik olan /api/muzibu/playlists/{id}/add-album
endpoint'i backend'e eklendi. Artık kullanıcılar albüme sağ tıklayıp tüm şarkılarını playliste ekleyebilir.
Dosya: Modules/Muzibu/routes/api.php (Satır 48)
Route::post('/{id}/add-song', [PlaylistController::class, 'addSong'])
->name('api.muzibu.playlists.add-song');
+ Route::post('/{id}/add-album', [PlaylistController::class, 'addAlbum'])
+ ->name('api.muzibu.playlists.add-album');
Route::post('/{id}/copy', [PlaylistController::class, 'copy'])
->name('api.muzibu.playlists.copy');
Dosya: PlaylistController.php (Satır 10)
use Modules\Muzibu\App\Models\Playlist;
use Modules\Muzibu\App\Models\Song;
+ use Modules\Muzibu\App\Models\Album;
use Modules\Muzibu\App\Services\PlaylistService;
Dosya: PlaylistController.php (Satır 280-340)
/**
* Add all songs from album to playlist
*/
public function addAlbum(Request $request, int $id): JsonResponse
{
try {
$request->validate([
'album_id' => 'required|integer|exists:muzibu_albums,album_id',
]);
$userId = auth()->id();
$albumId = $request->input('album_id');
// Get album with active songs
$album = Album::with(['songs' => function($query) {
$query->where('is_active', 1);
}])->findOrFail($albumId);
$songs = $album->songs;
if ($songs->isEmpty()) {
return response()->json([
'success' => false,
'message' => 'Albümde aktif şarkı bulunamadı',
], 400);
}
// Add all songs to playlist
$addedCount = 0;
$skippedCount = 0;
foreach ($songs as $song) {
$result = $this->playlistService->addSongToPlaylist(
$id,
$song->song_id,
$userId
);
if ($result['success']) {
$addedCount++;
} else {
$skippedCount++;
}
}
return response()->json([
'success' => true,
'added_count' => $addedCount,
'skipped_count' => $skippedCount,
'total_songs' => $songs->count(),
'message' => "{$addedCount} şarkı playliste eklendi"
. ($skippedCount > 0 ? " ({$skippedCount} zaten mevcuttu)" : ""),
]);
} catch (\Exception $e) {
Log::error('Add album to playlist error:', ['message' => $e->getMessage()]);
return response()->json([
'success' => false,
'message' => 'Albüm ekleme başarısız',
], 500);
}
}
['web', 'auth'] middleware korumasıwith(['songs'])added_count: Eklenen şarkı sayısıskipped_count: Zaten var olantotal_songs: Toplam şarkı400 Bad Request404 Not Found401 Unauthorized500 Internal ErrorPOST /api/muzibu/playlists/{id}/add-album
api.muzibu.playlists.add-album
['web', 'auth']
{ "album_id": 123 }
{
"success": true,
"added_count": 8,
"skipped_count": 2,
"total_songs": 10,
"message": "8 şarkı playliste eklendi (2 zaten mevcuttu)"
}