Add TagsController
ADD
app/Http/Controllers/TagsController.php
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+
+use Auth;
+use App\Tags;
+
+class TagsController extends Controller {
+ public function index() {
+ $tags = Auth::user()->tags;
+
+ return view('tags.index', compact('tags'));
+ }
+}

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

MODIFY
resources/views/layout.blade.php
resources/views/layout.blade.php
<li>
<a href="/budgets">Budgets</a>
</li>
+ <li>
+ <a href="/tags">Tags</a>
+ </li>
</ul>
<ul>
<li>

ADD
resources/views/tags/index.blade.php
+@extends('layout')
+
+@section('body')
+ <h1>Tags</h1>
+ <div class="box spacing-top-large">
+ <table>
+ <tbody>
+ @foreach ($tags as $tag)
+ <tr>
+ <td>{{ $tag->name }}</td>
+ </tr>
+ @endforeach
+ </tbody>
+ </table>
+ </div>
+@endsection

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

Add TagsController