koel/app/Models/Playlist.php

35 lines
609 B
PHP
Raw Normal View History

2015-12-13 04:42:28 +00:00
<?php
namespace App\Models;
use App\Traits\CanFilterByUser;
2016-08-03 10:42:11 +00:00
use Illuminate\Database\Eloquent\Collection;
2015-12-14 13:22:39 +00:00
use Illuminate\Database\Eloquent\Model;
2015-12-13 04:42:28 +00:00
2016-08-03 10:42:11 +00:00
/**
* @property int user_id
* @property Collection songs
*/
2015-12-13 04:42:28 +00:00
class Playlist extends Model
{
use CanFilterByUser;
protected $hidden = ['user_id', 'created_at', 'updated_at'];
protected $guarded = ['id'];
protected $casts = [
'user_id' => 'int',
];
public function songs()
{
return $this->belongsToMany(Song::class);
}
public function user()
{
return $this->belongsTo(User::class);
}
}