belongsToMany('App\Playlist'); } public function textTranspose($key) { $sc = new SongController(); $transp = $key; if ($key && $this->plain_key){ $try = $sc->keydiff($this->plain_key, $key); if ($try !== null){ $transp = $try; } } return $sc->transposeBlock($this->text, $transp); } public function getNameAttribute() { return $this->title . ( $this->author ? " ($this->author)" : "" ) . ($this->plain_key ? " ($this->plain_key)" : "") . ($this->verse ? " ($this->verse)" : ""); } public function getPlainKeyAttribute() { // 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; } }