Commit 5c0adae9 authored by Nicolas Widart's avatar Nicolas Widart

Adding unique check for primary menu

parent bcceec7c
......@@ -6,7 +6,10 @@ class UpdateMenuRequest extends FormRequest
{
public function rules()
{
return [];
return [
'name' => 'required',
'primary' => 'unique:menus',
];
}
public function authorize()
......@@ -16,6 +19,8 @@ class UpdateMenuRequest extends FormRequest
public function messages()
{
return [];
return [
'primary.unique' => 'Only one menu can be primary at a time.'
];
}
}
<div class='form-group{{ $errors->has('name') ? ' has-error' : '' }}'>
{!! Form::label('name', trans('menu::menu.form.name')) !!}
{!! Form::text('name', Input::old('name', $menu->name), ['class' => 'form-control', 'placeholder' => trans('menu::menu.form.name')]) !!}
{!! $errors->first('Name', '<span class="help-block">:message</span>') !!}
{!! $errors->first('name', '<span class="help-block">:message</span>') !!}
</div>
<div class="checkbox">
<div class="checkbox {{ $errors->has('primary') ? ' has-error' : '' }}">
<label for="primary">
<input id="primary"
name="primary"
......@@ -12,5 +12,6 @@
{{ ((bool)$menu->primary) ? 'checked' : '' }}
value="1" />
{{ trans('menu::menu.form.primary') }}
{!! $errors->first('primary', '<span class="help-block">:message</span>') !!}
</label>
</div>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment