| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace App\Providers;
- 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');
- }
- /**
- * Authorize Horizon with the admin guard.
- *
- * The default guard is customer, so the framework callback would inspect
- * the storefront user. Dashboard access follows the admin session instead.
- */
- protected function authorization(): void
- {
- $this->gate();
- Horizon::auth(function ($request) {
- return Gate::forUser($request->user('admin'))->check('viewHorizon')
- || app()->environment('local');
- });
- }
- /**
- * Register the Horizon gate.
- *
- * This gate determines who can access Horizon in non-local environments.
- */
- protected function gate(): void
- {
- Gate::define('viewHorizon', function ($user = null) {
- return in_array(optional($user)->email, [
- 'admin@longyi.com',
- ]);
- });
- }
- }
|