Backend for songs.zachdecook.com
New song: Supposedly fix creation of new song
| -rw-r--r-- | laravel/app/Http/Controllers/SongController.php | 1 | ||||
| -rw-r--r-- | laravel/app/Song.php | 2 |
2 files changed, 2 insertions, 1 deletions
diff --git a/laravel/app/Http/Controllers/SongController.php b/laravel/app/Http/Controllers/SongController.php index 36fdb3f..d4369ae 100644 --- a/laravel/app/Http/Controllers/SongController.php +++ b/laravel/app/Http/Controllers/SongController.php @@ -240,6 +240,7 @@ class SongController extends Controller if ( $_POST['playlist'] ) { $song->playlists()->attach( $_POST['playlist'] ); } + $song->text = $_POST['text']; // Workaround id issue. return redirect()->route('song.show', [ 'song' => $song, 'playlist' => $_POST['playlist'] ] ); } if ($_POST['playlist'] ){ diff --git a/laravel/app/Song.php b/laravel/app/Song.php index a50a5f0..99b0aa4 100644 --- a/laravel/app/Song.php +++ b/laravel/app/Song.php @@ -43,7 +43,7 @@ class Song extends Model public function setTextAttribute($text) { // Watch out, this saves immediately! - if ($text) { + if ($text && $this->id) { file_put_contents("public/text/{$this->id}.txt", $text); } } |