diff --git a/resources/views/regular_contract/create.blade.php b/resources/views/regular_contract/create.blade.php index c0d741a..d04a1d7 100644 --- a/resources/views/regular_contract/create.blade.php +++ b/resources/views/regular_contract/create.blade.php @@ -51,100 +51,101 @@ -
| - 駐輪場名 - - - | -- 市町村名 - - - | -- 駅名 - - - | -自転車 | -原付 | -自動二輪 | -自動車 | -
|---|---|---|---|---|---|---|
| - {{ $row->park_name }} - | -{{ $row->city_name }} | -{{ $row->station_neighbor_station }} | - {{-- 自転車・原付・自動二輪・自動車列 --}} - @foreach(['自転車', '原付', '自動二輪', '自動車'] as $vehicle) -- @php - $zonesForType = ($zones[$row->park_id] ?? collect())->where('psection_subject', $vehicle); - @endphp - @forelse ($zonesForType as $zone) - @php - $reserveCount = ($reserve[$row->park_id] ?? collect()) - ->where('psection_id', $zone->psection_id) - ->count(); - $vacancy = $zone->zone_tolerance - $zone->zone_number - $reserveCount; - // 猶予期間判定 - $grace = $city_grace_periods[$row->city_id] ?? null; - $now = \Carbon\Carbon::now(); - $inGrace = false; - if ($grace && $grace->update_grace_period_start_date && $grace->update_grace_period_start_time && $grace->update_grace_period_end_date && $grace->update_grace_period_end_time) { - $year = $now->year; - $month = $now->month; - $startDay = (int)$grace->update_grace_period_start_date; - $endDay = (int)$grace->update_grace_period_end_date; - if ($startDay > $endDay) { - // 月またぎ - // 前月の開始日~今月の終了日 - $prevMonth = $now->copy()->subMonth(); - $startPrev = \Carbon\Carbon::createFromFormat('Y-m-d H:i', sprintf('%04d-%02d-%02d %s', $prevMonth->year, $prevMonth->month, $startDay, $grace->update_grace_period_start_time)); - $endCurr = \Carbon\Carbon::createFromFormat('Y-m-d H:i', sprintf('%04d-%02d-%02d %s', $year, $month, $endDay, $grace->update_grace_period_end_time)); - // 今月の開始日~翌月の終了日 - $startCurr = \Carbon\Carbon::createFromFormat('Y-m-d H:i', sprintf('%04d-%02d-%02d %s', $year, $month, $startDay, $grace->update_grace_period_start_time)); - $nextMonth = $month == 12 ? 1 : $month + 1; - $nextYear = $month == 12 ? $year + 1 : $year; - $endNext = \Carbon\Carbon::createFromFormat('Y-m-d H:i', sprintf('%04d-%02d-%02d %s', $nextYear, $nextMonth, $endDay, $grace->update_grace_period_end_time)); - $inGrace = $now->between($startPrev, $endCurr) || $now->between($startCurr, $endNext); - } else { - // 同月 - $start = \Carbon\Carbon::createFromFormat('Y-m-d H:i', sprintf('%04d-%02d-%02d %s', $year, $month, $startDay, $grace->update_grace_period_start_time)); - $end = \Carbon\Carbon::createFromFormat('Y-m-d H:i', sprintf('%04d-%02d-%02d %s', $year, $month, $endDay, $grace->update_grace_period_end_time)); - $inGrace = $now->between($start, $end); - } - } - @endphp - @if ($vacancy > 0 && $inGrace) - - @elseif (!$inGrace) - - @elseif ($vacancy <= 0 && $inGrace) - - @endif - @empty - - @endforelse - | - @endforeach -|||
| 該当する駐輪場はありません。 | -||||||
| + 駐輪場名 + + + | ++ 市町村名 + + + | ++ 駅名 + + + | +自転車 | +原付 | +自動二輪 | +自動車 | +
|---|---|---|---|---|---|---|
| + {{ $row->park_name }} + | +{{ $row->city_name }} | +{{ $row->station_neighbor_station }} | + {{-- 自転車・原付・自動二輪・自動車列 --}} + @foreach(['自転車', '原付', '自動二輪', '自動車'] as $vehicle) ++ @php + $zonesForType = ($zones[$row->park_id] ?? collect())->where('psection_subject', $vehicle); + @endphp + @forelse ($zonesForType as $zone) + @php + $reserveCount = ($reserve[$row->park_id] ?? collect()) + ->where('psection_id', $zone->psection_id) + ->count(); + $vacancy = $zone->zone_tolerance - $zone->zone_number - $reserveCount; + // 猶予期間判定 + $grace = $city_grace_periods[$row->city_id] ?? null; + $now = \Carbon\Carbon::now(); + $inGrace = false; + if ($grace && $grace->update_grace_period_start_date && $grace->update_grace_period_start_time && $grace->update_grace_period_end_date && $grace->update_grace_period_end_time) { + $year = $now->year; + $month = $now->month; + $startDay = (int)$grace->update_grace_period_start_date; + $endDay = (int)$grace->update_grace_period_end_date; + if ($startDay > $endDay) { + // 月またぎ + // 前月の開始日~今月の終了日 + $prevMonth = $now->copy()->subMonth(); + $startPrev = \Carbon\Carbon::createFromFormat('Y-m-d H:i', sprintf('%04d-%02d-%02d %s', $prevMonth->year, $prevMonth->month, $startDay, $grace->update_grace_period_start_time)); + $endCurr = \Carbon\Carbon::createFromFormat('Y-m-d H:i', sprintf('%04d-%02d-%02d %s', $year, $month, $endDay, $grace->update_grace_period_end_time)); + // 今月の開始日~翌月の終了日 + $startCurr = \Carbon\Carbon::createFromFormat('Y-m-d H:i', sprintf('%04d-%02d-%02d %s', $year, $month, $startDay, $grace->update_grace_period_start_time)); + $nextMonth = $month == 12 ? 1 : $month + 1; + $nextYear = $month == 12 ? $year + 1 : $year; + $endNext = \Carbon\Carbon::createFromFormat('Y-m-d H:i', sprintf('%04d-%02d-%02d %s', $nextYear, $nextMonth, $endDay, $grace->update_grace_period_end_time)); + $inGrace = $now->between($startPrev, $endCurr) || $now->between($startCurr, $endNext); + } else { + // 同月 + $start = \Carbon\Carbon::createFromFormat('Y-m-d H:i', sprintf('%04d-%02d-%02d %s', $year, $month, $startDay, $grace->update_grace_period_start_time)); + $end = \Carbon\Carbon::createFromFormat('Y-m-d H:i', sprintf('%04d-%02d-%02d %s', $year, $month, $endDay, $grace->update_grace_period_end_time)); + $inGrace = $now->between($start, $end); + } + } + @endphp + @if ($vacancy > 0 && $inGrace) + + @elseif (!$inGrace) + + @elseif ($vacancy <= 0 && $inGrace) + + @endif + @empty + + @endforelse + | + @endforeach +|||
| 該当する駐輪場はありません。 | +||||||