From 480fd78c51bd7b3fac65c4e800855eb5227e00a0 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 28 Jul 2015 20:45:32 -0700 Subject: [PATCH] Disllow delete if parent --- app/lang/en/admin/locations/message.php | 2 +- app/models/Location.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/lang/en/admin/locations/message.php b/app/lang/en/admin/locations/message.php index 982d2b3603..3ba1eed3b6 100755 --- a/app/lang/en/admin/locations/message.php +++ b/app/lang/en/admin/locations/message.php @@ -5,7 +5,7 @@ return array( 'does_not_exist' => 'Location does not exist.', 'assoc_users' => 'This location is currently associated with at least one user and cannot be deleted. Please update your users to no longer reference this location and try again. ', 'assoc_assets' => 'This location is currently associated with at least one asset and cannot be deleted. Please update your assets to no longer reference this location and try again. ', - 'assoc_child_loc' => 'This location is currently the parent of at least one asset and cannot be deleted. Please update your locations to no longer reference this location and try again. ', + 'assoc_child_loc' => 'This location is currently the parent of at least one child location and cannot be deleted. Please update your locations to no longer reference this location and try again. ', 'create' => array( diff --git a/app/models/Location.php b/app/models/Location.php index 5f6fd95b38..8a83eaa809 100755 --- a/app/models/Location.php +++ b/app/models/Location.php @@ -33,7 +33,7 @@ class Location extends Elegant } public function childLocations() { - return $this->hasMany('Location','id')->where('parent_id','=',$this->id); + return $this->hasMany('Location','parent_id'); } public static function getLocationHierarchy($locations, $parent_id = null) {