diff --git a/app/Booking.php b/app/Booking.php index ed33aa1..129f928 100644 --- a/app/Booking.php +++ b/app/Booking.php @@ -109,4 +109,13 @@ class Booking extends Model { return $this->subBookings->count() === 1; } + + /** + * Get the date of the very first booking. + * + * @return string + */ + public static function firstDate() { + return Booking::min('date'); + } } diff --git a/resources/views/bookings/index.blade.php b/resources/views/bookings/index.blade.php index 95c7ef1..c0c9d88 100644 --- a/resources/views/bookings/index.blade.php +++ b/resources/views/bookings/index.blade.php @@ -25,8 +25,15 @@ Projekt @for ($month = 1; $month <= 12; $month++) - @if (date('Y') > $year - or (date('Y') == $year and date('m') >= $month)) + @if (( + date('Y') > $year + or (date('Y') == $year + and date('m') >= $month) + ) and ( + $firstDate['Y'] < $year + or $firstDate['Y'] == $year + and $firstDate['m'] <= $month + )) @@ -105,8 +112,15 @@ @endif @endforeach @endif - @if (date('Y') > $year - or (date('Y') == $year and date('m') >= $month)) + @if (( + date('Y') > $year + or (date('Y') == $year + and date('m') >= $month) + ) and ( + $firstDate['Y'] < $year + or $firstDate['Y'] == $year + and $firstDate['m'] <= $month + ))