Backend for songs.zachdecook.com
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?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");
    }
}