Skip to content

Commit d704c60

Browse files
fix: improve unit kerja ID retrieval logic in NaskahKeluar model
1 parent b6387f1 commit d704c60

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

app/Models/NaskahKeluar.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ protected static function booted(): void
2323
{
2424
static::saving(function (NaskahKeluar $naskah) {
2525
if ($naskah->isDirty(['jenis_naskah_id', 'tanggal', 'kode_arsip_id', 'derajat_naskah_id', 'unit_kerja_id'])) {
26-
$unit_kerja_id = $naskah->unit_kerja_id ?? optional(Helper::getDataPegawaiByUserId(Auth::user()->id, $naskah->tanggal))->unit_kerja_id;
26+
$pegawai = Helper::getDataPegawaiByUserId(Auth::user()->id, $naskah->tanggal);
27+
if (is_null($pegawai)) {
28+
$pegawai = Helper::getDataPegawaiByUserId(Auth::user()->id, now());
29+
}
30+
$unit_kerja_id = $naskah->unit_kerja_id ?? optional($pegawai)->unit_kerja_id;
2731
$nomor = Helper::nomor($naskah->tanggal, $naskah->jenis_naskah_id, $unit_kerja_id, $naskah->kode_arsip_id, $naskah->derajat_naskah_id);
2832
$naskah->nomor = $nomor['nomor'];
2933
$naskah->no_urut = $nomor['no_urut'];

0 commit comments

Comments
 (0)