From a5b180a9c62ac4faafed2f23608e5d2f830b870c Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 11 Dec 2019 10:46:07 -0800 Subject: [PATCH] Fixed Call to a member function count() on null for location delete --- app/Http/Controllers/LocationsController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/LocationsController.php b/app/Http/Controllers/LocationsController.php index 77776084ba..9bbc7a7540 100755 --- a/app/Http/Controllers/LocationsController.php +++ b/app/Http/Controllers/LocationsController.php @@ -199,16 +199,16 @@ class LocationsController extends Controller return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.not_found')); } - if ($location->users()->count() > 0) { + if (($location->users()) && ($location->users()->count() > 0)) { return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_users')); - } elseif ($location->children->count() > 0) { + } elseif (($location->children) && ($location->children->count() > 0)) { return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_child_loc')); - } elseif ($location->assets()->count() > 0) { + } elseif (($location->assets()) && ($location->assets()->count() > 0)) { return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_assets')); - } elseif ($location->assignedassets()->count() > 0) { + } elseif (($location->assignedassets()) && ($location->assignedassets()->count() > 0)) { return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_assets')); }