first commit
This commit is contained in:
44
app/Models/Permohonan.php
Normal file
44
app/Models/Permohonan.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class Permohonan extends Model
|
||||
{
|
||||
use HasFactory, LogsActivity;
|
||||
|
||||
protected $table = 'permohonan';
|
||||
|
||||
protected $fillable = [
|
||||
'no_rujukan', 'user_id', 'jabatan_id', 'vot_id', 'kategori', 'tujuan',
|
||||
'jumlah_keseluruhan', 'status', 'catatan', 'gambar_1', 'gambar_2',
|
||||
'status_semakan', 'catatan_semakan', 'reviewed_by', 'reviewed_at',
|
||||
'approved_by', 'approved_at', 'submitted_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'jumlah_keseluruhan' => 'decimal:2',
|
||||
'submitted_at' => 'datetime',
|
||||
'reviewed_at' => 'datetime',
|
||||
'approved_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()->logFillable()->logOnlyDirty();
|
||||
}
|
||||
|
||||
public function user() { return $this->belongsTo(User::class); }
|
||||
public function jabatan() { return $this->belongsTo(Jabatan::class, 'jabatan_id'); }
|
||||
public function vot() { return $this->belongsTo(Vot::class, 'vot_id'); }
|
||||
public function items() { return $this->hasMany(PermohonanItem::class, 'permohonan_id'); }
|
||||
public function reviewer() { return $this->belongsTo(User::class, 'reviewed_by'); }
|
||||
public function approver() { return $this->belongsTo(User::class, 'approved_by'); }
|
||||
}
|
||||
Reference in New Issue
Block a user