Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Platform
Commits
5c0adae9
Commit
5c0adae9
authored
Nov 22, 2014
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding unique check for primary menu
parent
bcceec7c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
4 deletions
+10
-4
UpdateMenuRequest.php
Http/Requests/UpdateMenuRequest.php
+7
-2
edit-fields.blade.php
Resources/views/admin/menus/partials/edit-fields.blade.php
+3
-2
No files found.
Http/Requests/UpdateMenuRequest.php
View file @
5c0adae9
...
...
@@ -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.'
];
}
}
Resources/views/admin/menus/partials/edit-fields.blade.php
View file @
5c0adae9
<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('
N
ame', '
<span
class=
"help-block"
>
:message
</span>
') !!}
{!! $errors->first('
n
ame', '
<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>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment