Backend for songs.zachdecook.com
Diffstat (limited to 'laravel/app/Song.php')
-rw-r--r--laravel/app/Song.php6
1 files changed, 6 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 = [