Display recent spendings on dashboard
MODIFY
app/Http/Controllers/DashboardController.php
app/Http/Controllers/DashboardController.php
@@ -50,6 +50,12 @@ class DashboardController extends Controller {
LIMIT 1;
', [$user->id, date('m')]);
+ $recentSpendings = $user
+ ->spendings()
+ ->orderBy('created_at', 'DESC')
+ ->limit(3)
+ ->get();
+
$tagsBreakdown = DB::select('
SELECT
tags.name AS name,
@@ -71,9 +77,12 @@ class DashboardController extends Controller {
'currency' => $user->currency,
'month' => date('n'),
+
'totalSpendings' => $totalSpendings,
'mostExpensiveTag' => $mostExpensiveTag,
'mostExpensiveWeekday' => $mostExpensiveWeekday,
+
+ 'recentSpendings' => $recentSpendings,
'tagsBreakdown' => $tagsBreakdown,
'earningsCount' => $user->earnings->count(),

MODIFY
resources/lang/dk/general.php
resources/lang/dk/general.php
@@ -10,5 +10,7 @@ return [
'analysis' => 'Analyse',
'earnings' => 'Indkomster',
- 'spendings' => 'Udgifter'
+ 'spendings' => 'Udgifter',
+
+ 'recent' => 'Seneste'
];

MODIFY
resources/lang/en/general.php
resources/lang/en/general.php
@@ -10,5 +10,7 @@ return [
'analysis' => 'Analysis',
'earnings' => 'Earnings',
- 'spendings' => 'Spendings'
+ 'spendings' => 'Spendings',
+
+ 'recent' => 'Recent'
];

MODIFY
resources/lang/nl/general.php
resources/lang/nl/general.php
@@ -10,5 +10,7 @@ return [
'analysis' => 'Analyse',
'earnings' => 'Inkomsten',
- 'spendings' => 'Uitgaven'
+ 'spendings' => 'Uitgaven',
+
+ 'recent' => 'Recente'
];

MODIFY
resources/views/dashboard.blade.php
resources/views/dashboard.blade.php
</div>
</div>
</div>
- @if (count($tagsBreakdown))
- <div class="box mb-4">
+ <div class="row row--gutter mb-4">
+ <div class="row__column">
+ <div style="color: black; margin-bottom: 20px;">{{ __('general.recent') }} {{ __('general.spendings') }}</div>
+ <div class="box">
+ @if (count($recentSpendings))
+ @foreach ($recentSpendings as $spending)
+ <div class="box__section row row--seperate">
+ <div class="row__column">{{ $spending->description }}</div>
+ <div class="row__column row__column--compact">{!! $currency->symbol !!} {{ $spending->formatted_amount }}</div>
+ </div>
+ @endforeach
+ @else
+ <div class="box__section">You don't have any spendings</div>
+ @endif
+ </div>
+ </div>
+ <div class="row__column">
+ <div class="box">
<div class="box__section">
<div class="mb-2">{{ __('general.analysis') }}</div>
+ @if (count($tagsBreakdown))
<div class="ct-chart ct-perfect-fifth" style="max-width: 500px; margin-left: auto; margin-right: auto;"></div>
+ @else
+ Not enough data
+ @endif
+ </div>
+ </div>
</div>
</div>
- @endif
<div class="row gutter spacing-bottom-large">
<div class="column">
<div class="box">

Display recent spendings on dashboard