2024-12-11 12:29:55 +07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
2026-06-01 15:01:03 +07:00
|
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
2024-12-11 12:29:55 +07:00
|
|
|
|
|
|
|
|
class FormUpCountry extends Model
|
|
|
|
|
{
|
|
|
|
|
use SoftDeletes;
|
|
|
|
|
|
|
|
|
|
protected $table = 'form_up_country';
|
2026-06-01 15:01:03 +07:00
|
|
|
|
2024-12-11 12:29:55 +07:00
|
|
|
protected $fillable = [
|
2026-06-01 15:01:03 +07:00
|
|
|
'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',
|
2024-12-11 12:29:55 +07:00
|
|
|
];
|
2024-12-16 17:01:55 +07:00
|
|
|
|
2026-06-01 15:01:03 +07:00
|
|
|
/**
|
|
|
|
|
* Relasi ke Admin (Pengaju).
|
|
|
|
|
*/
|
|
|
|
|
public function user(): BelongsTo
|
2024-12-16 17:01:55 +07:00
|
|
|
{
|
2026-06-01 15:01:03 +07:00
|
|
|
return $this->belongsTo(Admin::class, 'user_id');
|
2024-12-16 17:01:55 +07:00
|
|
|
}
|
|
|
|
|
|
2026-06-01 15:01:03 +07:00
|
|
|
/**
|
|
|
|
|
* Relasi ke Rayon.
|
|
|
|
|
*/
|
|
|
|
|
public function rayon(): BelongsTo
|
2024-12-16 17:01:55 +07:00
|
|
|
{
|
2026-06-01 15:01:03 +07:00
|
|
|
return $this->belongsTo(Rayon::class, 'rayon_id');
|
2024-12-16 17:01:55 +07:00
|
|
|
}
|
2025-10-13 10:55:21 +07:00
|
|
|
|
2026-06-01 15:01:03 +07:00
|
|
|
/**
|
|
|
|
|
* Relasi ke Attachments (Dokumen Digital) sesuai pola Entertainment.
|
|
|
|
|
*/
|
|
|
|
|
public function attachments(): HasMany
|
2025-10-13 10:55:21 +07:00
|
|
|
{
|
2026-06-01 15:01:03 +07:00
|
|
|
return $this->hasMany(AttachmentForm::class, 'form_id')
|
2025-10-13 10:55:21 +07:00
|
|
|
->where('table_name', \App\Enums\AttachmentTableName::FORM_UP_COUNTRY);
|
|
|
|
|
}
|
2026-06-01 15:01:03 +07:00
|
|
|
|
|
|
|
|
public function rejector() {
|
|
|
|
|
return $this->belongsTo(User::class, 'rejected_by');
|
2024-12-11 12:29:55 +07:00
|
|
|
}
|
2026-06-01 15:01:03 +07:00
|
|
|
}
|