2015-12-13 04:42:28 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use App\Traits\CanFilterByUser;
|
2015-12-14 13:22:39 +00:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2017-08-05 18:55:02 +00:00
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
2015-12-13 04:42:28 +00:00
|
|
|
|
|
|
|
/**
|
2016-08-03 10:42:11 +00:00
|
|
|
* @property bool liked
|
|
|
|
* @property int play_count
|
|
|
|
* @property Song song
|
|
|
|
* @property User user
|
2017-06-24 20:46:55 +00:00
|
|
|
* @property int id
|
2015-12-13 04:42:28 +00:00
|
|
|
*/
|
|
|
|
class Interaction extends Model
|
|
|
|
{
|
|
|
|
use CanFilterByUser;
|
|
|
|
|
|
|
|
protected $casts = [
|
|
|
|
'liked' => 'boolean',
|
|
|
|
'play_count' => 'integer',
|
|
|
|
];
|
|
|
|
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
|
2016-02-13 03:21:24 +00:00
|
|
|
protected $hidden = ['id', 'user_id', 'created_at', 'updated_at'];
|
2015-12-13 04:42:28 +00:00
|
|
|
|
2017-08-05 18:55:02 +00:00
|
|
|
/**
|
|
|
|
* An interaction belongs to a user.
|
|
|
|
*
|
|
|
|
* @return BelongsTo
|
|
|
|
*/
|
2015-12-13 04:42:28 +00:00
|
|
|
public function user()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(User::class);
|
|
|
|
}
|
|
|
|
|
2017-08-05 18:55:02 +00:00
|
|
|
/**
|
|
|
|
* An interaction is associated with a song.
|
|
|
|
*
|
|
|
|
* @return BelongsTo
|
|
|
|
*/
|
2015-12-13 04:42:28 +00:00
|
|
|
public function song()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Song::class);
|
|
|
|
}
|
|
|
|
}
|