koel/app/Models/Interaction.php

44 lines
1 KiB
PHP
Raw Normal View History

2015-12-13 04:42:28 +00:00
<?php
namespace App\Models;
use App\Traits\CanFilterByUser;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
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
/**
2020-09-06 21:20:42 +00:00
* @property bool $liked
* @property int $play_count
* @property Song $song
* @property User $user
* @property int $id
2019-11-29 21:23:58 +00:00
*
* @method self firstOrCreate(array $where, array $params = [])
* @method static self find(int $id)
* @method static Builder whereSongIdAndUserId(string $songId, string $userId)
2015-12-13 04:42:28 +00:00
*/
class Interaction extends Model
{
use CanFilterByUser;
use HasFactory;
2015-12-13 04:42:28 +00:00
protected $casts = [
'liked' => 'boolean',
'play_count' => 'integer',
];
protected $guarded = ['id'];
protected $hidden = ['id', 'user_id', 'created_at', 'updated_at'];
2015-12-13 04:42:28 +00:00
2018-08-24 15:27:19 +00:00
public function user(): BelongsTo
2015-12-13 04:42:28 +00:00
{
return $this->belongsTo(User::class);
}
2018-08-24 15:27:19 +00:00
public function song(): BelongsTo
2015-12-13 04:42:28 +00:00
{
return $this->belongsTo(Song::class);
}
}