Skip to content

A free open source IT asset/license management system

Ensure at the model level that location.id/user.id and location.parent_id/user.manager_id cannot be the same

snipec02adace6165
diff --git a/app/Models/Location.php b/app/Models/Location.php
index ff36010341..a99433ed96 100755
--- a/app/Models/Location.php
+++ b/app/Models/Location.php
@@ -20,13 +20,14 @@ class Location extends SnipeModel
protected $dates = ['deleted_at'];
protected $table = 'locations';
protected $rules = array(
- 'name' => 'required|min:2|max:255|unique_undeleted',
- 'city' => 'min:2|max:255|nullable',
- 'country' => 'min:2|max:2|nullable',
- 'address' => 'max:80|nullable',
- 'address2' => 'max:80|nullable',
- 'zip' => 'min:3|max:10|nullable',
- 'manager_id' => 'exists:users,id|nullable'
+ 'name' => 'required|min:2|max:255|unique_undeleted',
+ 'city' => 'min:2|max:255|nullable',
+ 'country' => 'min:2|max:2|nullable',
+ 'address' => 'max:80|nullable',
+ 'address2' => 'max:80|nullable',
+ 'zip' => 'min:3|max:10|nullable',
+ 'manager_id' => 'exists:users,id|nullable',
+ 'parent_id' => 'nullable|different:id',
);
/**
diff --git a/app/Models/User.php b/app/Models/User.php
index a9b94530d5..27c8b6ffeb 100755
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -71,6 +71,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
'password' => 'required|min:8',
'locale' => 'max:10|nullable',
'website' => 'url|nullable',
+ 'manager_id' => 'nullable|different:id',
];
use Searchable;