Backend for songs.zachdecook.com
Diffstat (limited to 'laravel/app/Song.php')
| -rw-r--r-- | laravel/app/Song.php | 5 |
1 files changed, 3 insertions, 2 deletions
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); |