Create partial named empty_state for when there aren't any resources
MODIFY
app/Http/Controllers/SpendingController.php
app/Http/Controllers/SpendingController.php
@@ -14,12 +14,16 @@ class SpendingController extends Controller {
$spendingsByMonth = [];
for ($month = 12; $month >= 1; $month --) {
- $spendingsByMonth[$month] = session('space')
+ $spendingsThisMonth = session('space')
->spendings()
->whereYear('happened_on', date('Y'))
->whereMonth('happened_on', $month)
->orderBy('happened_on', 'DESC')
->get();
+
+ if (count($spendingsThisMonth)) {
+ $spendingsByMonth[$month] = $spendingsThisMonth;
+ }
}
return view('spendings.index', compact('spendingsByMonth'));

MODIFY
resources/views/dashboard.blade.php
resources/views/dashboard.blade.php
<a href="/earnings">More <i class="far fa-arrow-right fa-xs"></i></a>
</div>
@else
- <div class="box__section">You don't have any earnings</div>
+ @include('partials.empty_state', ['payload' => 'earnings'])
@endif
</div>
</div>
<a href="/spendings">More <i class="far fa-arrow-right fa-xs"></i></a>
</div>
@else
- <div class="box__section">You don't have any spendings</div>
+ @include('partials.empty_state', ['payload' => 'spendings'])
@endif
</div>
</div>

MODIFY
resources/views/earnings/index.blade.php
resources/views/earnings/index.blade.php
</div>
@endforeach
@else
- <div class="box__section text-center">You don't have any earnings</div>
+ @include('partials.empty_state', ['payload' => 'earnings'])
@endif
</div>
</div>

ADD
resources/views/partials/empty_state.blade.php
+<div class="box__section text-center">
+ <div class="mb-1">There aren't any {{ $payload }} yet</div>
+ <a href="/{{ $payload }}/create" style="font-size: 14px;">Create</a>
+</div>

MODIFY
resources/views/recurrings/index.blade.php
resources/views/recurrings/index.blade.php
</div>
</div>
<div class="box mt-3">
+ @if (count($recurrings))
@foreach ($recurrings as $recurring)
<div class="box__section row">
<div class="row__column">
</div>
</div>
@endforeach
+ @else
+ @include('partials.empty_state', ['payload' => 'recurrings'])
+ @endif
</div>
</div>
@endsection

MODIFY
resources/views/spendings/index.blade.php
resources/views/spendings/index.blade.php
<a href="/spendings/create" class="button">Create Spending</a>
</div>
</div>
+ @if (count($spendingsByMonth))
@foreach ($spendingsByMonth as $index => $spendings)
@if (count($spendings))
<h3 class="mt-3 mb-2">{{ __('calendar.months.' . $index) }}</h3>
</div>
@endif
@endforeach
+ @else
+ <div class="box mt-3">
+ @include('partials.empty_state', ['payload' => 'spendings'])
+ </div>
+ @endif
</div>
@endsection

MODIFY
resources/views/tags/index.blade.php
resources/views/tags/index.blade.php
</div>
</div>
<div class="box">
+ @if (count($tags))
<div class="box__section box__section--header row">
<div class="row__column">Name</div>
<div class="row__column row__column--double" style="flex: 2;">Spendings</div>
</div>
@endforeach
</div>
+ @else
+ @include('partials.empty_state', ['payload' => 'tags'])
+ @endif
</div>
@endsection

Create partial named empty_state for when there aren't any resources