From f8eb022403b7aaceb97da1feaf9c84e4a2b8aec6 Mon Sep 17 00:00:00 2001 From: Lukas Halbritter Date: Thu, 4 Oct 2018 19:53:59 +0200 Subject: [PATCH] Added AccountType method numberAndName(). Fixed bug in bookings.index view: There is no error anymore when a booking has no project assigned. --- app/AccountType.php | 28 +++++++++++++++++++++--- resources/views/bookings/index.blade.php | 14 ++++++------ 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/app/AccountType.php b/app/AccountType.php index f2089d1..74b38e2 100644 --- a/app/AccountType.php +++ b/app/AccountType.php @@ -6,7 +6,11 @@ use Illuminate\Database\Eloquent\Model; class AccountType extends Model { - /* + /************************************************************************** + * DIRECT RELATIONS * + **************************************************************************/ + + /** * Get the account class of the account type. * * @return Illuminate\Database\Eloquent\Relations\BelongsTo @@ -15,8 +19,12 @@ class AccountType extends Model { return $this->belongsTo('App\AccountClass'); } - - /* + + /************************************************************************** + * INDIRECT RELATIONS * + **************************************************************************/ + + /** * Get the IO-type of the account type. * * @return Illuminate\Database\Eloquent\Relations\BelongsTo @@ -52,4 +60,18 @@ class AccountType extends Model }); })->get(); } + + /************************************************************************** + * INDIRECT PROPERTIES * + **************************************************************************/ + + /** + * Returns the name and number of the account-type as string. + * + * @return string + */ + public function numberAndName() + { + return $this->number . ' - ' . $this->name; + } } diff --git a/resources/views/bookings/index.blade.php b/resources/views/bookings/index.blade.php index 9230bdc..3beb002 100644 --- a/resources/views/bookings/index.blade.php +++ b/resources/views/bookings/index.blade.php @@ -3,7 +3,7 @@ @section('title', 'Kassenbuch') @section('subnav') - + Neue Buchung @endsection @section('content') @@ -60,12 +60,11 @@ @if ($booking->isSimple()) - {{ $booking->accountType()->number . ' - ' . - $booking->accountType()->name }} + {{ $booking->accountType()->numberAndName() }} @endif - @if ($booking->isSimple()) + @if ($booking->isSimple() and $booking->project() !== null) {{ $booking->project()->name }} @endif @@ -89,11 +88,12 @@ @endif - {{ $subBooking->accountType->number . ' - ' . - $subBooking->accountType->name }} + {{ $subBooking->accountType->numberAndName() }} - {{ $subBooking->project->name }} + @if ($subBooking->project !== null) + {{ $subBooking->project->name }} + @endif @endforeach