From 0586163907a153ebe1d506d8040aa574a0b6e0f3 Mon Sep 17 00:00:00 2001 From: Zach DeCook Date: Thu, 12 Aug 2021 17:28:53 +0000 Subject: * Song: Add audios --- laravel/app/Song.php | 6 ++++++ laravel/resources/views/song.blade.php | 3 +++ 2 files changed, 9 insertions(+) (limited to 'laravel') diff --git a/laravel/app/Song.php b/laravel/app/Song.php index fbbeac6..41fbea0 100644 --- a/laravel/app/Song.php +++ b/laravel/app/Song.php @@ -48,6 +48,12 @@ class Song extends Model // TODO: Replace keys from $chords with values from $words. return $chords; } + public function getAudioAttribute() + { + if (file_exists("public/music/{$this->id}.mp3")) { + return "/public/music/{$this->id}.mp3"; + } + } public static function chordTransform($chord) { $repl = [ diff --git a/laravel/resources/views/song.blade.php b/laravel/resources/views/song.blade.php index 5fdc847..57cae19 100644 --- a/laravel/resources/views/song.blade.php +++ b/laravel/resources/views/song.blade.php @@ -26,6 +26,9 @@

{{$song['title']}} - {{$song->author}}

+ @if($song->audio) +
+ @endif @if($song->key) Key: {{$song->key}}
@endif -- cgit 1.4.1