Update dashboard's controller and view to comply with updated database fields
MODIFY
app/Http/Controllers/DashboardController.php
app/Http/Controllers/DashboardController.php
@@ -10,18 +10,25 @@ 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;
+ $spendingsToday = $user
+ ->spendings()
+ ->whereRaw('DATE(happened_on) = ?', [date('Y-m-d')])
+ ->sum('amount');
+
+ $spendingsMonth = $user
+ ->spendings()
+ ->whereRaw('MONTH(happened_on) = ?', [date('m')])
+ ->sum('amount');
$recentEarnings = $user
->earnings()
- ->orderBy('date', 'DESC')
+ ->orderBy('happened_on', 'DESC')
->limit(3)
->get();
$recentSpendings = $user
->spendings()
- ->orderBy('date', 'DESC')
+ ->orderBy('happened_on', 'DESC')
->limit(3)
->get();

MODIFY
resources/views/dashboard.blade.php
resources/views/dashboard.blade.php
<div class="row">
<div class="column">
<div class="color-dark">{{ $earning->description }}</div>
- <div style="margin-top: 10px;">{{ intval((time() - strtotime($earning->date)) / 86400) }} day(s) ago</div>
+ <div style="margin-top: 10px;">{{ intval((time() - strtotime($earning->happened_on)) / 86400) }} day(s) ago</div>
</div>
- <div class="column text-align-right align-middle color-green">{{ $currency->symbol }} {{ $earning->amount }}</h3></div>
+ <div class="column text-align-right align-middle color-green">{{ $currency->symbol }} {{ number_format($earning->amount / 100, 2) }}</h3></div>
</div>
</li>
@endforeach
<div class="row">
<div class="column">
<div class="color-dark">{{ $spending->description }}</div>
- <div style="margin-top: 10px;">{{ intval((time() - strtotime($spending->date)) / 86400) }} day(s) ago</div>
+ <div style="margin-top: 10px;">{{ intval((time() - strtotime($spending->happened_on)) / 86400) }} day(s) ago</div>
</div>
- <div class="column text-align-right align-middle color-red">{{ $currency->symbol }} {{ $spending->amount }}</h3></div>
+ <div class="column text-align-right align-middle color-red">{{ $currency->symbol }} {{ number_format($spending->amount / 100, 2) }}</h3></div>
</div>
</li>
@endforeach

Update dashboard's controller and view to comply with updated database fields