Display earnings on dashboard
MODIFY
app/User.php
app/User.php
@@ -27,6 +27,10 @@ class User extends Authenticatable
'password', 'remember_token',
];
+ public function earnings() {
+ return $this->hasMany('App\Earning');
+ }
+
public function spendings() {
return $this->hasMany('App\Spending');
}

MODIFY
resources/views/dashboard.blade.php
resources/views/dashboard.blade.php
@extends('layout')
@section('body')
+ <h1>Earnings</h1>
+ <div class="box">
+ <ul class="box__section">
+ @foreach (Auth::user()->earnings as $earning)
+ <li>{{ $earning->description }}</li>
+ @endforeach
+ </ul>
+ </div>
<h1>Spendings</h1>
<div class="box">
<ul class="box__section">

Display earnings on dashboard