From eca9f257eba7ecedbb1d1ce1bf37fe6ee285ea6a Mon Sep 17 00:00:00 2001 From: Deon George Date: Sun, 11 Dec 2022 21:46:08 +1100 Subject: [PATCH] Only show Network Admin if the user is a ZC of a network --- app/Models/User.php | 10 +++++++ .../views/layouts/partials/sidebar.blade.php | 26 ++++++++++--------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/app/Models/User.php b/app/Models/User.php index 88708e6..24569c0 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -79,4 +79,14 @@ class User extends Authenticatable implements MustVerifyEmail { return FALSE; } + + /** + * Is this user a ZC of a domain? + * + * @return bool + */ + public function isZC(): bool + { + return $this->systems->pluck('addresses')->flatten()->where('role',Address::NODE_ZC)->count() > 0; + } } diff --git a/resources/views/layouts/partials/sidebar.blade.php b/resources/views/layouts/partials/sidebar.blade.php index e74ea04..dca384f 100644 --- a/resources/views/layouts/partials/sidebar.blade.php +++ b/resources/views/layouts/partials/sidebar.blade.php @@ -11,19 +11,21 @@ @auth -
-
Network Admin
-
Domains
-
Systems
-
Zones
-
Echoareas
-
Fileareas
-
+ @if ($user->isZC()) +
+
Network Admin
+
Domains
+
Systems
+
Zones
+
Echoareas
+
Fileareas
+
-
-
System Admin
-
This Host Systems
-
+
+
System Admin
+
This Host Systems
+
+ @endif @can('admin')