Files
expense/app/Models/FormUpCountry.php
root 1c1418f3e0
Deploy to VPS (PAT over HTTPS) / deploy (push) Has been cancelled
Initial commit - expense
2026-06-01 15:01:03 +07:00

64 lines
1.8 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class FormUpCountry extends Model
{
use SoftDeletes;
protected $table = 'form_up_country';
protected $fillable = [
'expense_number', 'user_id', 'rayon_id', 'tanggal', 'tujuan', 'jarak',
'allowance', 'transport_dalkot', 'transport_ankot', 'hotel', 'total',
'approved_allowance', 'approved_transport_dalkot', 'approved_transport_ankot',
'approved_hotel', 'approved_total', 'bukti_allowance', 'bukti_transport_dalkot',
'bukti_transport_ankot', 'bukti_hotel', 'uc_plan', 'account_number', 'status',
'remarks', 'approved_at', 'approved2_at', 'approved_by', 'approved2_by',
'final_approved_at', 'final_approved_by','cabang_id','kategori_id',
];
/**
* 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 Rayon.
*/
public function rayon(): BelongsTo
{
return $this->belongsTo(Rayon::class, 'rayon_id');
}
/**
* Relasi ke Attachments (Dokumen Digital) sesuai pola Entertainment.
*/
public function attachments(): HasMany
{
return $this->hasMany(AttachmentForm::class, 'form_id')
->where('table_name', \App\Enums\AttachmentTableName::FORM_UP_COUNTRY);
}
public function rejector() {
return $this->belongsTo(User::class, 'rejected_by');
}
}