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

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

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

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

Get rid of index function for EarningsController