From 085b53b12866de6c095553bf2809641994e2d4cb Mon Sep 17 00:00:00 2001 From: Zach DeCook Date: Fri, 12 Feb 2021 00:15:24 +0000 Subject: gemini: show chords based on transposition --- laravel/app/Song.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'laravel/app') diff --git a/laravel/app/Song.php b/laravel/app/Song.php index 102a0ca..46472c4 100644 --- a/laravel/app/Song.php +++ b/laravel/app/Song.php @@ -36,9 +36,10 @@ class Song extends Model // TODO: Validate that this is plain. return trim($this->key, "m"); } - public function getChordsAttribute() + public function getChordsAttribute($txt = null) { - $txt = str_replace(['(',')',"\n"]," ",$this->text); + $txt = $txt ?? $this->text; + $txt = str_replace(['(',')',"\n", "\r"]," ",$txt); $words = array_flip(explode(' ', $txt)); $allChords = json_decode(file_get_contents("public/js/chordsdata/chords.json"), TRUE); $chords = array_intersect_key($allChords, $words); -- cgit 1.4.1