lasthourcloud/app/Providers/HorizonServiceProvider.php

42 lines
1003 B
PHP
Raw Permalink Normal View History

2023-05-10 07:26:25 +00:00
<?php
namespace App\Providers;
use App\Models\User;
use Illuminate\Support\Facades\Gate;
use Laravel\Horizon\Horizon;
use Laravel\Horizon\HorizonApplicationServiceProvider;
class HorizonServiceProvider extends HorizonApplicationServiceProvider
{
/**
* Bootstrap any application services.
*/
public function boot(): void
{
parent::boot();
// Horizon::routeSmsNotificationsTo('15556667777');
// Horizon::routeMailNotificationsTo('example@example.com');
// Horizon::routeSlackNotificationsTo('slack-webhook-url', '#channel');
Horizon::night();
}
/**
* Register the Horizon gate.
*
* This gate determines who can access Horizon in non-local environments.
*/
protected function gate(): void
{
2023-05-10 07:28:53 +00:00
Gate::define('viewHorizon', function ($user) {
$root_user = User::find(0);
2024-06-10 20:43:34 +00:00
2023-05-10 07:26:25 +00:00
return in_array($user->email, [
2024-06-10 20:43:34 +00:00
$root_user->email,
2023-05-10 07:26:25 +00:00
]);
});
}
}