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
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Playlist extends Model
{
	public $fillable = ['name'];
    public function songs()
    {
        return $this->belongsToMany('App\Song');
    }
    public function getM3uAttribute()
    {
        $output = "#EXTM3U\n";
        foreach($this->songs as $song) {
            if ($song->audio){
                $output .= config('app.url') . $song->audio . "\n";
            }
        }
        return $output;
    }
}