From 86c33f5ea3069f4aae746dc3b0daf50afc5e1ce1 Mon Sep 17 00:00:00 2001 From: Mohamed Alsharaf Date: Tue, 10 May 2016 23:08:29 +1200 Subject: [PATCH] Add unique validation to tag name field Fixes #89 --- app/Form/Tag.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Form/Tag.php b/app/Form/Tag.php index 330b85595..d13cdfd07 100644 --- a/app/Form/Tag.php +++ b/app/Form/Tag.php @@ -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', ];