Permalink
Browse files

Define validation rules for estimates

  • Loading branch information...
lovett committed Jan 10, 2019
1 parent 716fe5d commit db04ef636887fd6a629a631cd91e6e3cd1dadcb3
Showing with 24 additions and 4 deletions.
  1. +10 −1 app/Http/Requests/EstimateRequest.php
  2. +14 −3 resources/views/estimate/form.blade.php
@@ -31,7 +31,16 @@ public function authorize()
*/
public function rules()
{
return [];
return [
'name' => 'required',
'submitted' => 'nullable|date_format:Y-m-d',
'status' => 'required',
'recipient' => 'nullable',
'client_id' => 'nullable|exists:clients,id',
'fee' => 'nullable|numeric',
'hours' => 'nullable|numeric',
'summary' => 'nullable',
];
}
/**
@@ -30,13 +30,24 @@
<div class="input-group-prepend">
<span class="input-group-text">$</span>
</div>
{!! Form::text('fee', $model->fee, ['class' => 'form-control']) !!}

@php($fieldClasses = ['form-control'])
@if ($errors->has('fee'))
@php($fieldClasses[] = 'is-invalid')
@endif
{!! Form::text('fee', $model->fee, ['class' => $fieldClasses]) !!}
@include('partials.form-field-error', ['name' => 'fee'])
</div>
</div>

{!! Form::label('hours', 'Hours', ['class' => 'col-sm-1 col-form-label']) !!}
<div class="col-sm-2">
{!! Form::text('hours', $model->hours, ['class' => 'form-control']) !!}
<div class="col-sm-3">
@php($fieldClasses = ['form-control'])
@if ($errors->has('hours'))
@php($fieldClasses[] = 'is-invalid')
@endif
{!! Form::text('hours', $model->hours, ['class' => $fieldClasses]) !!}
@include('partials.form-field-error', ['name' => 'hours'])
</div>
</div>

0 comments on commit db04ef6

Please sign in to comment.