54 lines
1.4 KiB
PHP
54 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class FormVehicleRunningCost extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'form_vehicle_running_cost';
|
|
|
|
protected $fillable = [
|
|
'expense_number', 'user_id', 'tanggal', 'liter', 'total', 'approved_total',
|
|
'jarak', 'tipe_bensin', 'nopol', 'keterangan', 'bukti_total', 'account_number',
|
|
'type', 'status', 'remarks', 'approved_at', 'approved2_at', 'approved_by',
|
|
'approved2_by', 'final_approved_at', 'final_approved_by',
|
|
];
|
|
|
|
/**
|
|
* Casts untuk otomatisasi format Carbon pada tanggal.
|
|
*/
|
|
protected $casts = [
|
|
'tanggal' => 'date',
|
|
'final_approved_at' => 'datetime',
|
|
'created_at' => 'datetime',
|
|
'updated_at' => 'datetime',
|
|
];
|
|
|
|
/**
|
|
* Relasi ke Admin (Pengaju)
|
|
*/
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Admin::class, 'user_id');
|
|
}
|
|
|
|
/**
|
|
* Relasi ke Attachments (Dokumen Digital)
|
|
*/
|
|
public function attachments(): HasMany
|
|
{
|
|
return $this->hasMany(AttachmentForm::class, 'form_id')
|
|
->where('table_name', \App\Enums\AttachmentTableName::FORM_VEHICLE_RUNNING_COST);
|
|
}
|
|
|
|
public function rejector() {
|
|
return $this->belongsTo(User::class, 'rejected_by');
|
|
}
|
|
|
|
} |