about summary refs log tree commit diff
path: root/laravel/app
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2021-01-05 03:51:16 +0000
committerZach DeCook <zachdecook@librem.one>2021-01-05 03:51:16 +0000
commit4492535d2a36287b92e31e0af4e82be9c14bef9e (patch)
treef3436c6f25563ff6b5acd89b662f939325069ced /laravel/app
parentbb67d222cee63fa6f36f04f5644141f9a6b68254 (diff)
downloadprosongsa-4492535d2a36287b92e31e0af4e82be9c14bef9e.tar.gz
* Song: Detect chords
Diffstat (limited to 'laravel/app')
-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;
+    }
 }