Display total spendings of today and this month on dashboard
MODIFY
app/Http/Controllers/DashboardController.php
app/Http/Controllers/DashboardController.php
@@ -10,6 +10,9 @@ class DashboardController extends Controller {
public function index() {
$user = Auth::user();
+ $spendingsToday = $user->spendings()->whereRaw('DATE(date) = ?', [date('Y-m-d')])->sum('amount') * 100;
+ $spendingsMonth = $user->spendings()->whereRaw('MONTH(date) = ?', [date('m')])->sum('amount') * 100;
+
$recentEarnings = $user
->earnings()
->orderBy('date', 'DESC')
@@ -24,6 +27,10 @@ class DashboardController extends Controller {
return view('dashboard', [
'currency' => $user->currency,
+
+ 'spendingsToday' => $spendingsToday,
+ 'spendingsMonth' => $spendingsMonth,
+
'recentEarnings' => $recentEarnings,
'recentSpendings' => $recentSpendings
]);

MODIFY
app/Http/Controllers/TagsController.php
app/Http/Controllers/TagsController.php
@@ -36,7 +36,10 @@ class TagsController extends Controller {
}
public function destroy(Tag $tag) {
+
+ if ($tag->somethign) {
$tag->delete();
+ }
return redirect('/settings');
}

MODIFY
resources/assets/sass/components/helpers.scss
resources/assets/sass/components/helpers.scss
text-align: center;
}
+.mt-1 {
+ margin-top: 10px;
+}
+
+.mb-4 {
+ margin-bottom: 40px;
+}
+
.ml-2 {
margin-left: 20px;
}

MODIFY
resources/views/dashboard.blade.php
resources/views/dashboard.blade.php
@section('body')
<div class="wrapper spacing-top-large spacing-bottom-large">
+ <div class="row row--gutter mb-4">
+ <div class="row__column">
+ <div class="box">
+ <div class="box__section">
+ <h2>{{ $currency->symbol }} {{ number_format($spendingsToday / 100, 2) }}</h2>
+ <div class="mt-1">Spent today</div>
+ </div>
+ </div>
+ </div>
+ <div class="row__column">
+ <div class="box">
+ <div class="box__section">
+ <h2>{{ $currency->symbol }} {{ number_format($spendingsMonth / 100, 2) }}</h2>
+ <div class="mt-1">Spent this month</div>
+ </div>
+ </div>
+ </div>
+ </div>
<div class="row gutter spacing-bottom-large">
<div class="column">
<div class="color-dark spacing-bottom-large">Recent Earnings</div>

Display total spendings of today and this month on dashboard