about summary refs log tree commit diff
path: root/laravel/app/Song.php
diff options
context:
space:
mode:
Diffstat (limited to 'laravel/app/Song.php')
-rw-r--r--laravel/app/Song.php8
1 files changed, 8 insertions, 0 deletions
diff --git a/laravel/app/Song.php b/laravel/app/Song.php
index 4ae3920..102a0ca 100644
--- a/laravel/app/Song.php
+++ b/laravel/app/Song.php
@@ -36,4 +36,12 @@ class Song extends Model
         // TODO: Validate that this is plain.
         return trim($this->key, "m");
     }
+    public function getChordsAttribute()
+    {
+        $txt = str_replace(['(',')',"\n"]," ",$this->text);
+        $words = array_flip(explode(' ', $txt));
+        $allChords = json_decode(file_get_contents("public/js/chordsdata/chords.json"), TRUE);
+        $chords = array_intersect_key($allChords, $words);
+        return $chords;
+    }
 }