From 925af53d3dc9e2d5b0d45ab5c44b1bd64d35b8c8 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 10 Jan 2025 19:00:18 +0100 Subject: [PATCH] horizon gate --- app/Providers/HorizonServiceProvider.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/Providers/HorizonServiceProvider.php b/app/Providers/HorizonServiceProvider.php index efe17cd7ec..44d5593ea3 100644 --- a/app/Providers/HorizonServiceProvider.php +++ b/app/Providers/HorizonServiceProvider.php @@ -4,8 +4,10 @@ use App\Contracts\CustomJobRepositoryInterface; use App\Models\ApplicationDeploymentQueue; +use App\Models\User; use App\Repositories\CustomJobRepository; use Illuminate\Support\Facades\Event; +use Illuminate\Support\Facades\Gate; use Illuminate\Support\ServiceProvider; use Laravel\Horizon\Contracts\JobRepository; use Laravel\Horizon\Events\JobReserved; @@ -42,6 +44,16 @@ public function boot(): void ]); } }); + } + + protected function gate(): void + { + Gate::define('viewHorizon', function ($user) { + $root_user = User::find(0); + return in_array($user->email, [ + $root_user->email, + ]); + }); } }