Validate creation of new earnings
MODIFY
app/Http/Controllers/EarningsController.php
app/Http/Controllers/EarningsController.php
@@ -26,6 +26,12 @@ class EarningsController extends Controller {
}
public function store(Request $request) {
+ $request->validate([
+ 'date' => 'required|date|date_format:Y-m-d',
+ 'description' => 'required|max:255',
+ 'amount' => 'required|regex:/^\d*(\.\d{1,2})?$/'
+ ]);
+
$earning = new Earning;
$earning->user_id = Auth::user()->id;

MODIFY
resources/views/earnings/create.blade.php
resources/views/earnings/create.blade.php
<div class="input input--small">
<label>Date</label>
<DatePicker></DatePicker>
+ @include('partials.validation_error', ['payload' => 'date'])
</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">
<label>Amount</label>
<input type="text" name="amount" />
+ @include('partials.validation_error', ['payload' => 'amount'])
</div>
<button>@lang('actions.create')</button>
</form>

Validate creation of new earnings