Add create and store methods to RecurringController
MODIFY
app/Http/Controllers/RecurringController.php
app/Http/Controllers/RecurringController.php
@@ -22,4 +22,33 @@ class RecurringController extends Controller {
return view('recurrings.show', compact('recurring'));
}
+
+ public function create() {
+ $user = Auth::user();
+
+ return view('recurrings.create', [
+ 'tags' => $user->tags
+ ]);
+ }
+
+ public function store(Request $request) {
+ // TODO VALIDATE
+
+ $user = Auth::user();
+
+ $recurring = new Recurring;
+
+ $recurring->user_id = $user->id;
+ $recurring->type = 'monthly';
+ $recurring->day = $request->input('day');
+ $recurring->starts_on = date('Y-m-d');
+ $recurring->ends_on = $request->input('end');
+ $recurring->tag_id = $request->input('tag');
+ $recurring->description = $request->input('description');
+ $recurring->amount = (int) ($request->input('amount') * 100);
+
+ $recurring->save();
+
+ return redirect()->route('recurrings.show', ['id' => $recurring->id]);
+ }
}

ADD
resources/views/recurrings/create.blade.php
+@extends('layout')
+
+@section('title', __('actions.create') . ' ' . __('general.recurring'))
+
+@section('body')
+ <div class="wrapper my-3">
+ <h2>{{ __('actions.create') }} {{ __('general.recurring') }}</h2>
+ <div class="box mt-3">
+ <form method="POST" action="/recurrings">
+ {{ csrf_field() }}
+ <div class="box__section row">
+ <div class="row__column">
+ <div class="input input--small">
+ <label>Day</label>
+ <input type="text" name="day" />
+ <div style="font-weight: 700; font-size: 14px; margin-top: 5px;">1 - 28</div>
+ @include('partials.validation_error', ['payload' => 'day'])
+ </div>
+ <div class="input input--small mb-0">
+ <label>End</label>
+ <DatePicker name="end"></DatePicker>
+ @include('partials.validation_error', ['payload' => 'end'])
+ </div>
+ </div>
+ <div class="row__column">
+ <div class="input input--small">
+ <label>Tag</label>
+ <select name="tag">
+ <option value="">-</option>
+ @foreach ($tags as $tag)
+ <option value="{{ $tag->id }}">{{ $tag->name }}</option>
+ @endforeach
+ </select>
+ @include('partials.validation_error', ['payload' => 'tag'])
+ </div>
+ <div class="input input--small">
+ <label>Description</label>
+ <input type="text" name="description" />
+ @include('partials.validation_error', ['payload' => 'description'])
+ </div>
+ <div class="input input--small mb-0">
+ <label>Amount</label>
+ <input type="text" name="amount" />
+ @include('partials.validation_error', ['payload' => 'amount'])
+ </div>
+ </div>
+ </div>
+ <div class="box__section box__section--highlight row row--right">
+ <div class="row__column row__column--compact row__column--middle">
+ <a href="/tags">Cancel</a>
+ </div>
+ <div class="row__column row__column--compact ml-2">
+ <button class="button">{{ __('actions.create') }}</button>
+ </div>
+ </div>
+ </form>
+ </div>
+ </div>
+@endsection

MODIFY
routes/web.php
routes/web.php
@@ -23,7 +23,12 @@ Route::group(['middleware' => ['auth']], function () {
'destroy'
]);
- Route::resource('/recurrings', 'RecurringController')->only(['index', 'show']);
+ Route::resource('/recurrings', 'RecurringController')->only([
+ 'index',
+ 'create',
+ 'store',
+ 'show'
+ ]);
Route::resource('/tags', 'TagController')->only([
'index',

Add create and store methods to RecurringController