From c02adace616527a1802a359c53396eb9728350bf Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 21 Apr 2020 19:51:20 -0700 Subject: [PATCH] Ensure at the model level that location.id/user.id and location.parent_id/user.manager_id cannot be the same --- app/Models/Location.php | 15 ++++++++------- app/Models/User.php | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) 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;