From ae6238a0b44782fc9b4d224055866892108b09f0 Mon Sep 17 00:00:00 2001 From: Lukas Halbritter Date: Fri, 12 Oct 2018 12:05:04 +0200 Subject: [PATCH] Monthly summarys now are only displayed for months after the first booking. --- app/Booking.php | 9 +++++++++ resources/views/bookings/index.blade.php | 22 ++++++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) 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 + ))