You've already forked Atomcms-edit
39 lines
862 B
PHP
Executable File
39 lines
862 B
PHP
Executable File
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Concerns\BelongsToUser;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class RadioGiveawayParticipant extends Model
|
|
{
|
|
use BelongsToUser;
|
|
|
|
#[\Override]
|
|
protected $table = 'radio_giveaway_participants';
|
|
|
|
#[\Override]
|
|
protected $guarded = ['id', 'created_at', 'updated_at', 'user_id', 'giveaway_id'];
|
|
|
|
/** @var array<string, string> */
|
|
#[\Override]
|
|
protected $casts = [
|
|
'joined_at' => 'datetime',
|
|
];
|
|
|
|
public function giveaway(): BelongsTo
|
|
{
|
|
return $this->belongsTo(RadioGiveaway::class);
|
|
}
|
|
|
|
public function hasJoined(User $user): bool
|
|
{
|
|
return $this->where('giveaway_id', $this->giveaway_id)
|
|
->where('user_id', $user->id)
|
|
->exists();
|
|
}
|
|
}
|