Get rid of index function for SpendingsController
MODIFY
app/Http/Controllers/SpendingsController.php
app/Http/Controllers/SpendingsController.php
@@ -10,18 +10,6 @@ use App\Tag;
use Auth;
class SpendingsController extends Controller {
- public function index() {
- $user = Auth::user();
-
- $spendings = $user->spendings()
- ->orderBy('date', 'DESC')
- ->get();
-
- $currency = $user->currency;
-
- return view('spendings.index', compact('spendings', 'currency'));
- }
-
public function show($id) {
$user = Auth::user();

MODIFY
resources/views/dashboard/index.blade.php
resources/views/dashboard/index.blade.php
<li>
<div class="row">
<div class="column">
- <a href="#">{{ $spending->description }}</a>
+ <a href="/spendings/{{ $spending->id }}">{{ $spending->description }}</a>
<p class="spacing-top-nano">{{ $spending->tag->name }} &middot; {{ date('jS', strtotime($spending->date)) }}</p>
</div>
<div class="column align-right align-middle">

MODIFY
resources/views/layout.blade.php
resources/views/layout.blade.php
<li>
<a href="/budgets">Budgets</a>
</li>
- <li>
- <a href="/spendings">Spendings</a>
- </li>
<li>
<a href="/tags">Tags</a>
</li>

DELETE
resources/views/spendings/index.blade.php
-@extends('layout')
-
-@section('body')
- <div class="row spacing-bottom-large">
- <div class="column align-middle">
- <h1>Spendings</h1>
- </div>
- <div class="column align-right">
- <a href="/spendings/create" class="button">Create</a>
- </div>
- </div>
- <div class="box">
- <table>
- <tbody>
- @foreach ($spendings as $spending)
- <tr>
- <td>{{ date('F jS, Y', strtotime($spending->date)) }}</td>
- <td>{{ $currency->symbol }} {{ $spending->amount }}</td>
- <td>{{ $spending->description }}</td>
- <td>
- <form class="test" method="POST" action="/spendings/{{ $spending->id }}">
- {{ method_field('DELETE') }}
- {{ csrf_field() }}
- <input type="submit" value="Delete" />
- </form>
- </td>
- </tr>
- @endforeach
- </tbody>
- </table>
- </div>
-@endsection

MODIFY
routes/web.php
routes/web.php
@@ -13,7 +13,7 @@ Route::group(['middleware' => ['auth']], function () {
Route::resource('/earnings', 'EarningsController', ['only' => ['show', 'create', 'store', 'destroy']]);
- Route::resource('/spendings', 'SpendingsController', ['only' => ['index', 'show', 'create', 'store', 'destroy']]);
+ Route::resource('/spendings', 'SpendingsController', ['only' => ['show', 'create', 'store', 'destroy']]);
Route::resource('/budgets', 'BudgetsController', ['only' => ['index', 'create', 'store', 'destroy']]);

Get rid of index function for SpendingsController