fix(api): only sync kontrakan status based on sewa bookings, not survei

This commit is contained in:
micko samawa 2026-06-29 09:31:43 +07:00
parent 6557d4aa5f
commit d9f70573f6
1 changed files with 4 additions and 2 deletions

View File

@ -29,9 +29,10 @@ protected static function boot()
*/ */
public static function syncKontrakanStatus($kontrakanId) public static function syncKontrakanStatus($kontrakanId)
{ {
// Cek apakah ada booking checked_in // Cek apakah ada booking checked_in (sewa)
$hasCheckedIn = static::where('kontrakan_id', $kontrakanId) $hasCheckedIn = static::where('kontrakan_id', $kontrakanId)
->where('status', self::STATUS_CHECKED_IN) ->where('status', self::STATUS_CHECKED_IN)
->where('jenis_pengajuan', 'sewa')
->exists(); ->exists();
if ($hasCheckedIn) { if ($hasCheckedIn) {
@ -39,9 +40,10 @@ public static function syncKontrakanStatus($kontrakanId)
return; return;
} }
// Cek apakah ada booking confirmed atau pending // Cek apakah ada booking confirmed atau pending (sewa)
$hasActiveOrPending = static::where('kontrakan_id', $kontrakanId) $hasActiveOrPending = static::where('kontrakan_id', $kontrakanId)
->whereIn('status', [self::STATUS_CONFIRMED, self::STATUS_PENDING]) ->whereIn('status', [self::STATUS_CONFIRMED, self::STATUS_PENDING])
->where('jenis_pengajuan', 'sewa')
->exists(); ->exists();
if ($hasActiveOrPending) { if ($hasActiveOrPending) {