Skip to content

Commit

Permalink
Add unique validation to tag name field
Browse files Browse the repository at this point in the history
Fixes #89
  • Loading branch information
satrun77 committed May 10, 2016
1 parent f089cf0 commit 86c33f5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/Form/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,11 @@ public function fields()
*/
public function rules()
{
// Tag to exclude in unique test while editing
$excludeTag = $this->isEditing()? ',' . $this->getModel()->id : '';

$rules = [
'name' => 'required|max:200',
'name' => 'required|max:200|unique:tags,name' . $excludeTag,
'parent_id' => 'required',
'bgcolor' => 'required',
];
Expand Down

0 comments on commit 86c33f5

Please sign in to comment.