38 lines
843 B
PHP
38 lines
843 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Sppm\Dun;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Support\Str;
|
|
|
|
class SesiTaklimat extends Model
|
|
{
|
|
protected $table = 'sesi_taklimat';
|
|
protected $guarded = [];
|
|
|
|
protected $casts = [
|
|
'tarikh' => 'date',
|
|
'is_active' => 'boolean',
|
|
];
|
|
|
|
protected static function booted(): void
|
|
{
|
|
static::creating(function (SesiTaklimat $sesi) {
|
|
$sesi->qr_token ??= Str::random(32);
|
|
});
|
|
}
|
|
|
|
public function dun(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Dun::class, 'dun_id');
|
|
}
|
|
|
|
public function kehadiran(): HasMany
|
|
{
|
|
return $this->hasMany(KehadiranTaklimat::class, 'sesi_taklimat_id');
|
|
}
|
|
}
|