54 lines
1.3 KiB
PHP
54 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Facilitator;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Str;
|
|
|
|
class Facilitator extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
// Menentukan nama tabel jika tidak jamak (optional)
|
|
protected $table = 'facilitator';
|
|
|
|
// Karena ID menggunakan UUID (string), kita nonaktifkan auto-incrementing
|
|
public $incrementing = false;
|
|
protected $keyType = 'string';
|
|
|
|
protected $fillable = [
|
|
'id',
|
|
'user_email',
|
|
'full_name',
|
|
'role',
|
|
'village',
|
|
'district',
|
|
'regency',
|
|
'province',
|
|
'phone',
|
|
'is_active',
|
|
'created_date',
|
|
];
|
|
|
|
protected $casts = [
|
|
'id' => 'string',
|
|
'is_active' => 'boolean',
|
|
'created_date' => 'datetime',
|
|
];
|
|
|
|
// Boot method untuk otomatis mengisi UUID saat create
|
|
protected static function boot()
|
|
{
|
|
parent::boot();
|
|
static::creating(function ($model) {
|
|
if (empty($model->id)) {
|
|
$model->id = (string) Str::uuid();
|
|
}
|
|
});
|
|
}
|
|
|
|
// Jika ingin menggunakan created_date dari JSON sebagai pengganti created_at Laravel
|
|
const CREATED_AT = 'created_date';
|
|
const UPDATED_AT = null; // Matikan jika tidak ada kolom updated_at
|
|
} |