Display spendings on dashboard
MODIFY
app/User.php
app/User.php
@@ -26,4 +26,8 @@ class User extends Authenticatable
protected $hidden = [
'password', 'remember_token',
];
+
+ public function spendings() {
+ return $this->hasMany('App\Spending');
+ }
}

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

Display spendings on dashboard