Backend for songs.zachdecook.com
Diffstat (limited to 'laravel/app/Http/Controllers/PlaylistController.php')
-rw-r--r--laravel/app/Http/Controllers/PlaylistController.php12
1 files changed, 12 insertions, 0 deletions
diff --git a/laravel/app/Http/Controllers/PlaylistController.php b/laravel/app/Http/Controllers/PlaylistController.php
index 49b1f35..c055601 100644
--- a/laravel/app/Http/Controllers/PlaylistController.php
+++ b/laravel/app/Http/Controllers/PlaylistController.php
@@ -15,4 +15,16 @@ class PlaylistController extends Controller
}
abort(404);
}
+ public function post($playlistName, $songID)
+ {
+ $pl = Playlist::where('name',$playlistName)->first();
+ if (!$pl){
+ $pl = new Playlist();
+ $pl->name = $playlistName;
+ }
+ $pl->save();
+ $pl->songs()->attach($songID);
+ // Do people want to see the favorites playlist when they've added to it, or stay on the song?
+ return redirect()->route('playlist.show', [ 'playlist' => $playlistName]);
+ }
}