2015-12-13 12:42:28 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
2020-11-14 17:57:25 +01:00
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
2015-12-14 08:22:39 -05:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2017-08-05 19:55:02 +01:00
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
2015-12-13 12:42:28 +08:00
|
|
|
|
|
|
|
/**
|
2020-09-06 23:20:42 +02:00
|
|
|
* @property bool $liked
|
2021-06-05 12:47:56 +02:00
|
|
|
* @property int $play_count
|
2020-09-06 23:20:42 +02:00
|
|
|
* @property Song $song
|
|
|
|
* @property User $user
|
2021-06-05 12:47:56 +02:00
|
|
|
* @property int $id
|
2019-11-29 22:23:58 +01:00
|
|
|
*
|
2021-06-04 17:19:33 +02:00
|
|
|
* @method static self firstOrCreate(array $where, array $params = [])
|
2020-11-14 17:57:25 +01:00
|
|
|
* @method static self find(int $id)
|
|
|
|
* @method static Builder whereSongIdAndUserId(string $songId, string $userId)
|
2021-06-04 17:19:33 +02:00
|
|
|
* @method static Builder whereIn(...$params)
|
2015-12-13 12:42:28 +08:00
|
|
|
*/
|
|
|
|
class Interaction extends Model
|
|
|
|
{
|
2020-11-14 17:57:25 +01:00
|
|
|
use HasFactory;
|
2015-12-13 12:42:28 +08:00
|
|
|
|
|
|
|
protected $casts = [
|
|
|
|
'liked' => 'boolean',
|
|
|
|
'play_count' => 'integer',
|
|
|
|
];
|
2021-06-05 12:47:56 +02:00
|
|
|
|
2015-12-13 12:42:28 +08:00
|
|
|
protected $guarded = ['id'];
|
2016-02-13 11:21:24 +08:00
|
|
|
protected $hidden = ['id', 'user_id', 'created_at', 'updated_at'];
|
2015-12-13 12:42:28 +08:00
|
|
|
|
2018-08-24 17:27:19 +02:00
|
|
|
public function user(): BelongsTo
|
2015-12-13 12:42:28 +08:00
|
|
|
{
|
|
|
|
return $this->belongsTo(User::class);
|
|
|
|
}
|
|
|
|
|
2018-08-24 17:27:19 +02:00
|
|
|
public function song(): BelongsTo
|
2015-12-13 12:42:28 +08:00
|
|
|
{
|
|
|
|
return $this->belongsTo(Song::class);
|
|
|
|
}
|
|
|
|
}
|