Skip to content

Commit

Permalink
Define validation rules for estimates
Browse files Browse the repository at this point in the history
  • Loading branch information
lovett committed Jan 10, 2019
1 parent 716fe5d commit db04ef6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
11 changes: 10 additions & 1 deletion app/Http/Requests/EstimateRequest.php
Expand Up @@ -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',
];
}

/**
Expand Down
17 changes: 14 additions & 3 deletions resources/views/estimate/form.blade.php
Expand Up @@ -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>

Expand Down

0 comments on commit db04ef6

Please sign in to comment.