From c414ebd0536cf53948a17de05880daa215299361 Mon Sep 17 00:00:00 2001 From: Deon George Date: Tue, 28 May 2024 23:21:54 +1000 Subject: [PATCH] Created a 'zc' role to be used when a user is a ZC of a domain, or a site admin --- app/Providers/AuthServiceProvider.php | 8 ++-- .../views/layouts/partials/sidebar.blade.php | 43 +++++++++++-------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index bb6cb31..a851ea5 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -27,8 +27,10 @@ class AuthServiceProvider extends ServiceProvider { $this->registerPolicies(); - Gate::define('admin',function (User $o) { - return $o->admin === TRUE; - }); + // Mailer Admin + Gate::define('admin',fn(User $o)=>($o->admin === TRUE)); + + // ZC of a Zone + Gate::define('zc',fn(User $o)=>(($o->admin === TRUE) || $o->ZC())); } } diff --git a/resources/views/layouts/partials/sidebar.blade.php b/resources/views/layouts/partials/sidebar.blade.php index c58933e..74c39fa 100644 --- a/resources/views/layouts/partials/sidebar.blade.php +++ b/resources/views/layouts/partials/sidebar.blade.php @@ -2,28 +2,33 @@ FTN Networks @auth -
-
My Systems
- @foreach ($user->systems->sortBy('name') as $o) -
{{ $o->name }}
- @endforeach -
+ @if($user->systems->count()) +
+
My Systems
+ @foreach ($user->systems->sortBy('name') as $o) +
{{ $o->name }}
+ @endforeach +
+ @endif @endauth -
-
Explore Networks
- @foreach (\App\Models\Domain::select(['id','name']) - ->when(((! $user) || (! $user->isAdmin())),function($query) { return $query->public()->active(); }) - ->orderBy('name') - ->get() as $o) - @if ($o->isManaged()) -
{{ $o->name }}
- @endif - @endforeach -
+ @if(($x=\App\Models\Domain::select(['id','name']) + ->when(((! $user) || (! $user->isAdmin())),fn($query)=>$query->public()->active()) + ->orderBy('name') + ->get()) + ->count()) +
+
Explore Networks
+ @foreach ($x as $o) + @if ($o->isManaged()) +
{{ $o->name }}
+ @endif + @endforeach +
+ @endif @auth - @if ($user->isZC()) + @can('zc')
Network Admin
Domains
@@ -32,7 +37,7 @@
Echoareas
Fileareas
- @endif + @endcan @can('admin')