Skip to content

Instantly share code, notes, and snippets.

@afiqiqmal
Created May 26, 2018 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afiqiqmal/77ce56a26b28d7081f5c38b6686e8a4d to your computer and use it in GitHub Desktop.
Save afiqiqmal/77ce56a26b28d7081f5c38b6686e8a4d to your computer and use it in GitHub Desktop.
Horizon Service Provider to distinguish access for valid user only
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Laravel\Horizon\Horizon;
use Zizaco\Entrust\Entrust;
class HorizonServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
Horizon::auth(function ($request) {
return auth()->user()->can('horizon_access') && auth()->check();
});
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
//
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment