Add show function to RecurringController
MODIFY
app/Http/Controllers/RecurringController.php
app/Http/Controllers/RecurringController.php
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
+use App\Recurring;
use Auth;
class RecurringController extends Controller {
@@ -15,4 +16,16 @@ class RecurringController extends Controller {
'recurrings' => $user->recurrings()->orderBy('created_at', 'DESC')->get()
]);
}
+
+ public function show($id) {
+ $recurring = Recurring::find($id);
+
+ if (!$recurring) {
+ // REEE
+ }
+
+ return view('recurrings.show', [
+ 'recurring' => $recurring
+ ]);
+ }
}

MODIFY
resources/views/recurrings/index.blade.php
resources/views/recurrings/index.blade.php
@foreach ($recurrings as $recurring)
<div class="box__section row">
<div class="row__column">
- <div class="color-dark">{{ $recurring->description }}</div>
+ <div class="color-dark">
+ <a href="/recurrings/{{ $recurring->id }}">{{ $recurring->description }}</a>
+ </div>
<div class="row mt-1">
<div class="row__column row__column--compact" style="font-size: 14px; font-weight: 600;">{!! $currency->symbol !!} {{ number_format($recurring->amount / 100, 2) }}</div>
@if ($recurring->due_days)

ADD
resources/views/recurrings/show.blade.php
+@extends('layout')
+
+@section('body')
+ <div class="wrapper my-4">
+ <div class="color-dark mb-2">{{ $recurring->description }}</div>
+ <div class="row mb-4">
+ <div class="row__column row__column--compact">
+ @if ($recurring->due_days)
+ <span style="border-radius: 5px; background: #D8F9E8; color: #51B07F; padding: 5px 10px; font-size: 14px; font-weight: 600;"><i class="fas fa-check fa-xs"></i> Active</span>
+ @else
+ <span style="border-radius: 5px; background: #FFE7EC; color: #F25C68; padding: 5px 10px; font-size: 14px; font-weight: 600;"><i class="fas fa-times fa-xs"></i> Inactive</span>
+ @endif
+ </div>
+ @if ($recurring->tag)
+ <div class="row__column row__column--compact ml-1">
+ <span style="border-radius: 5px; background: #DEEAFE; color: #618DD7; padding: 5px 10px; font-size: 14px; font-weight: 600;"><i class="fas fa-tag fa-xs"></i> {{ $recurring->tag->name }}</span>
+ </div>
+ @endif
+ </div>
+ <div class="color-dark mb-2">{{ __('general.spendings') }}</div>
+ <div class="box">
+ @if (count($recurring->spendings))
+ @foreach ($recurring->spendings as $spending)
+ <div class="box__section">
+ <div>
+ <div class="color-dark">{{ $spending->happened_on }}</div>
+ <div class="mt-1" style="font-size: 14px; font-weight: 600;">{{ $spending->formatted_happened_on }}</div>
+ </div>
+ <div></div>
+ </div>
+ @endforeach
+ @else
+ <div class="box__section text-center">There aren't any spendings (yet)</div>
+ @endif
+ </div>
+ </div>
+@endsection

MODIFY
routes/web.php
routes/web.php
@@ -21,7 +21,7 @@ Route::group(['middleware' => ['auth']], function () {
Route::post('/spendings', 'SpendingsController@store');
Route::delete('/spendings/{spending}', 'SpendingsController@destroy')->middleware('can:delete,spending');
- Route::resource('/recurrings', 'RecurringController')->only(['index']);
+ Route::resource('/recurrings', 'RecurringController')->only(['index', 'show']);
Route::get('/tags', 'TagsController@index')->name('tags');
Route::get('/tags/create', 'TagsController@create')->name('tags.create');

Add show function to RecurringController