facilitator
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
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 = 'user_details';
|
||||
|
||||
// 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
|
||||
}
|
||||
Reference in New Issue
Block a user