first
This commit is contained in:
48
app/Models/DrawSession.php
Normal file
48
app/Models/DrawSession.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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']
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user