From 6b5a0983eec0c22a37eb638906925ca9224edceb Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 12 Jul 2017 19:34:45 -0700 Subject: [PATCH] Added model validation to custom fieldsets --- app/Models/CustomFieldset.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/Models/CustomFieldset.php b/app/Models/CustomFieldset.php index 62b2f1a2e8..c89d3dd312 100644 --- a/app/Models/CustomFieldset.php +++ b/app/Models/CustomFieldset.php @@ -3,6 +3,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; use Gate; +use Watson\Validating\ValidatingTrait; class CustomFieldset extends Model { @@ -12,6 +13,17 @@ class CustomFieldset extends Model "name" => "required|unique:custom_fieldsets" ]; + /** + * Whether the model should inject it's identifier to the unique + * validation rules before attempting validation. If this property + * is not set in the model it will default to true. + * + * @var boolean + */ + protected $injectUniqueIdentifier = true; + use ValidatingTrait; + + public function fields() { return $this->belongsToMany('\App\Models\CustomField')->withPivot(["required","order"])->orderBy("pivot_order");