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\BelongsTo;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
2024-12-11 12:29:55 +07:00
|
|
|
|
|
|
|
|
class FormOthers extends Model
|
|
|
|
|
{
|
|
|
|
|
use SoftDeletes;
|
|
|
|
|
|
|
|
|
|
protected $table = 'form_others';
|
|
|
|
|
protected $fillable = [
|
2026-06-01 15:01:03 +07:00
|
|
|
'expense_number', 'user_id', 'kategori_id', 'tanggal', 'keterangan',
|
|
|
|
|
'total', 'approved_total', 'bukti_total', 'account_number', 'status',
|
|
|
|
|
'remarks', 'approved_at', 'approved2_at', 'approved_by', 'approved2_by',
|
|
|
|
|
'final_approved_at', 'final_approved_by',
|
2024-12-11 12:29:55 +07:00
|
|
|
];
|
2024-12-20 11:07:07 +07:00
|
|
|
|
2026-06-01 15:01:03 +07:00
|
|
|
/**
|
|
|
|
|
* Casts untuk otomatisasi format Carbon pada tanggal agar konsisten di Blade.
|
|
|
|
|
*/
|
|
|
|
|
protected $casts = [
|
|
|
|
|
'tanggal' => 'date',
|
|
|
|
|
'final_approved_at' => 'datetime',
|
|
|
|
|
'created_at' => 'datetime',
|
|
|
|
|
'updated_at' => 'datetime',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Relasi ke Admin (Pengaju).
|
|
|
|
|
*/
|
|
|
|
|
public function user(): BelongsTo
|
2024-12-20 11:07:07 +07:00
|
|
|
{
|
2026-06-01 15:01:03 +07:00
|
|
|
return $this->belongsTo(Admin::class, 'user_id');
|
2024-12-20 11:07:07 +07:00
|
|
|
}
|
|
|
|
|
|
2026-06-01 15:01:03 +07:00
|
|
|
/**
|
|
|
|
|
* Relasi ke Kategori.
|
|
|
|
|
*/
|
|
|
|
|
public function kategori(): BelongsTo
|
2024-12-20 11:07:07 +07:00
|
|
|
{
|
2026-06-01 15:01:03 +07:00
|
|
|
return $this->belongsTo(Kategori::class, 'kategori_id');
|
2024-12-20 11:07:07 +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
|
|
|
{
|
|
|
|
|
return $this->hasMany(\App\Models\AttachmentForm::class, 'form_id')
|
|
|
|
|
->where('table_name', \App\Enums\AttachmentTableName::FORM_OTHERS);
|
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
}
|