about summary refs log tree commit diff
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2021-08-12 17:28:53 +0000
committerZach DeCook <zachdecook@librem.one>2021-08-12 17:28:53 +0000
commit0586163907a153ebe1d506d8040aa574a0b6e0f3 (patch)
treead5725eb3bd4ecee5959b70015f8590f85e63865
parent4d067731f62f1abf07633881666975fd623c18b6 (diff)
downloadprosongsa-0586163907a153ebe1d506d8040aa574a0b6e0f3.tar.gz
* Song: Add audios
-rw-r--r--laravel/app/Song.php6
-rw-r--r--laravel/resources/views/song.blade.php3
2 files changed, 9 insertions, 0 deletions
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 @@
     </div>
 
     <h4>{{$song['title']}} - {{$song->author}}</h4>
+    @if($song->audio)
+        <audio controls src="{{$song->audio}}"></audio><br/>
+    @endif
     @if($song->key)
         Key: {{$song->key}}<br/>
     @endif