Skip to content

Commit 2211831

Browse files
authored
Merge pull request #2202 from opensource-workshop/OW-2577
[施設予約] 「重複予約を許可しない」設定にしていても、予約の終了時間を「24:00」にすると重複して予約ができてしまう不具合対応
2 parents c653f6d + bcded15 commit 2211831

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

app/Rules/CustomValiDuplicateBookings.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
namespace App\Rules;
44

5+
use App\Models\User\Reservations\ReservationsInput;
56
use Illuminate\Contracts\Validation\Rule;
6-
77
use Illuminate\Support\Collection;
8-
9-
use App\Models\User\Reservations\ReservationsInput;
8+
use Carbon\Carbon;
109

1110
/**
1211
* 施設予約重複チェック
@@ -34,6 +33,16 @@ public function __construct(int $facility_id, Collection $input_ids, string $sta
3433
$this->start_datetime = $start_datetime;
3534
$this->end_datetime = $end_datetime;
3635

36+
// 終了日時を日付と時間に分割
37+
[$end_date, $end_time] = explode(' ', $this->end_datetime);
38+
if ($end_time == '24:00') {
39+
// 予約重複できない設定+2025-05-30 14:00-17:00予定あり時、2025-05-30 12:00-24:00の予約が重複登録できてしまう不具合対応。end_datatimeの'2025-05-30 24:00'は不正な値でチェックできないため、'2025-05-31 00:00'に変換する
40+
$end_carbon = new Carbon($end_datetime);
41+
$this->end_datetime = $end_carbon->format('Y-m-d H:i');
42+
} else {
43+
$this->end_datetime = $end_datetime;
44+
}
45+
3746
$this->message = $message;
3847
}
3948

0 commit comments

Comments
 (0)