Files
cabutan-bertuah-koipb/app/Models/DrawSession.php
2026-06-24 18:30:00 +08:00

49 lines
1.0 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class DrawSession extends Model
{
protected $attributes = [
'is_active' => true,
'return_cancelled_to_pool' => true,
];
protected $fillable = [
'nama',
'is_active',
'return_cancelled_to_pool',
'started_by',
];
protected function casts(): array
{
return [
'is_active' => 'boolean',
'return_cancelled_to_pool' => 'boolean',
];
}
public function results(): HasMany
{
return $this->hasMany(DrawResult::class);
}
public function startedBy(): BelongsTo
{
return $this->belongsTo(User::class, 'started_by');
}
public static function active(): self
{
return static::firstOrCreate(
['is_active' => true],
['nama' => 'Mesyuarat Agung Tahunan KOIPB']
);
}
}