Skip to content

Commit d1c304e

Browse files
committed
Refactor date comparisons to use whereDate method for improved accuracy
1 parent 62b3e16 commit d1c304e

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

app/Console/Commands/SendReminder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function handle()
3030
$tanggal = date('Y-m-d');
3131
$reminders = DaftarReminder::with('daftarKegiatan')
3232
->where('tanggal', $tanggal)
33-
->where('waktu_kirim', '<=', date('H:i:s'))
33+
->whereTime('waktu_kirim', '<=', date('H:i:s'))
3434
->where('status', '!=', 'sent')
3535
->get();
3636
foreach ($reminders as $reminder) {

app/Helpers/Helper.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ public static function cekStokPersediaan($id, $tanggal = null)
363363
)
364364
->where('master_persediaan_id', $id)
365365
->when($tanggal, function ($query, $tanggal) {
366-
return $query->where('tanggal_transaksi', '<=', $tanggal);
366+
return $query->whereDate('tanggal_transaksi', '<=', $tanggal);
367367
})
368368
->groupBy('master_persediaan_id')
369369
->first();
@@ -716,7 +716,7 @@ public static function nomor($tanggal, $jenis_naskah_id, $unit_kerja_id = null,
716716
$no_urut = $max_no_urut + 1;
717717
$segmen = 0;
718718
} else {
719-
$no_urut = $naskah->where('tanggal', '<=', $tanggal)->max('no_urut') ?? 1;
719+
$no_urut = $naskah->whereDate('tanggal', '<=', $tanggal)->max('no_urut') ?? 1;
720720
$segmen = NaskahKeluar::whereYear('tanggal', $tahun)
721721
->where('kode_naskah_id', self::getPropertyFromCollection($kode_naskah, 'id'))
722722
->where('no_urut', $no_urut)
@@ -758,7 +758,7 @@ public static function getUsersByPengelola($role, $tanggal)
758758
$usersIdByUnitKerja = DataPegawai::cache()
759759
->get('all')
760760
->where('unit_kerja_id', self::getPropertyFromCollection(self::getDataPegawaiByUserId(Auth::user()->id, $tanggal), 'unit_kerja_id'))
761-
->where('tanggal', '<=', $tanggal)
761+
->whereDate('tanggal', '<=', $tanggal)
762762
->pluck('user_id')
763763
->toArray();
764764
$koordinatorsId = array_intersect($usersIdByPengelola, $usersIdByUnitKerja);
@@ -807,7 +807,7 @@ public static function setDefaultPesertaRapat($tujuan, $tanggal)
807807
*/
808808
public static function getDataPegawaiByUserId($user_id, $tanggal)
809809
{
810-
return DataPegawai::cache()->get('all')->where('user_id', $user_id)->where('tanggal', '<=', $tanggal)->sortByDesc('tanggal')->first();
810+
return DataPegawai::cache()->get('all')->where('user_id', $user_id)->whereDate('tanggal', '<=', $tanggal)->sortByDesc('tanggal')->first();
811811
}
812812

813813
/**
@@ -1644,7 +1644,7 @@ public static function getTemplatePathById($id)
16441644
*/
16451645
public static function getLatestTataNaskahId($tanggal)
16461646
{
1647-
return self::getPropertyFromCollection(TataNaskah::cache()->get('all')->where('tanggal', '<=', $tanggal)->sortByDesc('tanggal')->first(), 'id');
1647+
return self::getPropertyFromCollection(TataNaskah::cache()->get('all')->whereDate('tanggal', '<=', $tanggal)->sortByDesc('tanggal')->first(), 'id');
16481648
}
16491649

16501650
/**
@@ -1666,7 +1666,7 @@ public static function getLatestHargaSatuanId($tanggal)
16661666
*/
16671667
public static function getLatestHargaSatuan($tanggal)
16681668
{
1669-
return HargaSatuan::cache()->get('all')->where('tanggal', '<=', $tanggal)->sortByDesc('tanggal')->first();
1669+
return HargaSatuan::cache()->get('all')->whereDate('tanggal', '<=', $tanggal)->sortByDesc('tanggal')->first();
16701670
}
16711671

16721672
/**

0 commit comments

Comments
 (0)