mirror of
https://github.com/koel/koel
synced 2024-12-26 04:23:05 +00:00
43 lines
1 KiB
PHP
43 lines
1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Traits\CanFilterByUser;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* @property bool $liked
|
|
* @property int $play_count
|
|
* @property Song $song
|
|
* @property User $user
|
|
* @property int $id
|
|
*
|
|
* @method self firstOrCreate(array $where, array $params = [])
|
|
* @method static self find(int $id)
|
|
* @method static Builder whereSongIdAndUserId(string $songId, string $userId)
|
|
*/
|
|
class Interaction extends Model
|
|
{
|
|
use CanFilterByUser;
|
|
use HasFactory;
|
|
|
|
protected $casts = [
|
|
'liked' => 'boolean',
|
|
'play_count' => 'integer',
|
|
];
|
|
protected $guarded = ['id'];
|
|
protected $hidden = ['id', 'user_id', 'created_at', 'updated_at'];
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function song(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Song::class);
|
|
}
|
|
}
|