<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Song extends Model
{
public $fillable = ['number', 'title', 'author', 'key', 'text'];
public function playlists()
{
return $this->belongsToMany('App\Playlist');
}
public function getNameAttribute()
{
return $this->title
. ( $this->author ? " ($this->author)" : "" )
. ($this->plain_key ? " ($this->plain_key)" : "");
}
public function getPlainKeyAttribute()
{
// TODO: Validate that this is plain.
return trim($this->key, "m");
}
}