Add BudgetsController
ADD
app/Http/Controllers/BudgetsController.php
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+
+use Auth;
+
+class BudgetsController extends Controller {
+ public function index() {
+ $user = Auth::user();
+
+ $currency = $user->currency->symbol;
+
+ $budgets = $user->budgets()
+ ->orderBy('year', 'DESC')
+ ->orderBy('month', 'DESC')
+ ->get();
+
+ return view('budgets.index', compact('currency', 'budgets'));
+ }
+}

MODIFY
app/User.php
app/User.php
@@ -35,6 +35,10 @@ class User extends Authenticatable
return $this->hasMany('App\Spending');
}
+ public function budgets() {
+ return $this->hasMany('App\Budget');
+ }
+
public function currency() {
return $this->belongsTo('App\Currency');
}

ADD
resources/views/budgets/index.blade.php
+@extends('layout')
+
+@section('body')
+ <h1>Budgets</h1>
+ <div class="box spacing-top-large">
+ <table>
+ <tbody>
+ @foreach ($budgets as $budget)
+ <tr>
+ <td>@lang('months.' . $budget->month), {{ $budget->year }}</td>
+ <td>{{ $currency }} {{ $budget->amount }}</td>
+ <td>{{ $budget->tag->name }}</td>
+ </tr>
+ @endforeach
+ </tbody>
+ </table>
+ </div>
+@endsection

MODIFY
routes/web.php
routes/web.php
@@ -10,6 +10,8 @@ Route::group(['middleware' => ['auth']], function () {
Route::resource('/spendings', 'SpendingsController', ['only' => ['create', 'store']]);
+ Route::resource('/budgets', 'BudgetsController', ['only' => ['index']]);
+
Route::get('/reports', 'ReportsController@index')->name('reports.index');
Route::get('/reports/{year}/{month}', 'ReportsController@show')->name('reports.show');

Add BudgetsController