Display total earnings of the month on dashboard
MODIFY
app/Http/Controllers/DashboardController.php
app/Http/Controllers/DashboardController.php
@@ -13,6 +13,11 @@ class DashboardController extends Controller {
$space_id = session('space')->id;
+ $totalEarnings = session('space')
+ ->earnings()
+ ->whereRaw('MONTH(happened_on) = ?', [date('m')])
+ ->sum('amount');
+
$totalSpendings = session('space')
->spendings()
->whereRaw('MONTH(happened_on) = ?', [date('m')])
@@ -49,6 +54,7 @@ class DashboardController extends Controller {
'month' => date('n'),
+ 'totalEarnings' => $totalEarnings,
'totalSpendings' => $totalSpendings,
'recentSpendings' => $recentSpendings,

MODIFY
resources/lang/en/general.php
resources/lang/en/general.php
return [
'dashboard' => 'Dashboard',
+ 'total_earned' => 'Total Earned',
'total_spent' => 'Total Spent',
'most_expensive_tag' => 'Most Expensive Tag',
'most_expensive_day' => 'Most Expensive Day',

MODIFY
resources/lang/nl/general.php
resources/lang/nl/general.php
return [
'dashboard' => 'Overzicht',
+ 'total_earned' => 'Totaal Verdiend',
'total_spent' => 'Totaal Uitgegeven',
'most_expensive_tag' => 'Duurste Etiket',
'most_expensive_day' => 'Duurste Dag',
@@ -28,6 +29,6 @@ return [
'language' => 'Taal',
'theme' => 'Thema',
- 'recurrings' => 'Terugkerenden'm
+ 'recurrings' => 'Terugkerenden',
'recurring' => 'Terugkerend'
];

MODIFY
resources/views/dashboard.blade.php
resources/views/dashboard.blade.php
<p class="mt-1">{{ __('calendar.months.' . $month) }} {{ date('Y') }}</p>
<div class="row row--gutter row--responsive mt-3 mb-4">
<div class="row__column">
- <div class="card card--blue">
- <h2 style="font-size: 20px;">{!! $currency !!} {{ number_format($totalSpendings / 100, 2) }}</h2>
- <div class="mt-1" style="color: #A7AEBB;">{{ __('general.total_spent') }}</div>
+ <div class="card card--green">
+ <h2 style="font-size: 20px;">{!! $currency !!} {{ number_format($totalEarnings / 100, 2) }}</h2>
+ <div class="mt-1" style="color: #A7AEBB;">{{ __('general.total_earned') }}</div>
</div>
</div>
<div class="row__column">
- <!-- EMPTY -->
+ <div class="card card--red">
+ <h2 style="font-size: 20px;">{!! $currency !!} {{ number_format($totalSpendings / 100, 2) }}</h2>
+ <div class="mt-1" style="color: #A7AEBB;">{{ __('general.total_spent') }}</div>
+ </div>
</div>
<div class="row__column">
- <!-- EMPTY -->
+ <!-- OFFSET -->
</div>
</div>
<div class="row row--gutter row--responsive mb-4">

Display total earnings of the month on dashboard