You've already forked Atomcms-edit
Initial commit
This commit is contained in:
Executable
+38
@@ -0,0 +1,38 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user