Total Complexity | 3 |
Total Lines | 28 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
8 | class HeyManServiceProvider extends ServiceProvider |
||
9 | { |
||
10 | public function boot() |
||
11 | { |
||
12 | $this->defineGates(); |
||
13 | |||
14 | $this->loadMigrationsFrom(__DIR__.'/migrations'); |
||
15 | (new RouteAuthorizer())->authorizeMatchedRoutes($this->app); |
||
16 | } |
||
17 | |||
18 | public function register() |
||
19 | { |
||
20 | $this->app->singleton(HeyMan::class, HeyMan::class); |
||
21 | $this->app->singleton('hey_man_authorizer', ConditionApplier::class); |
||
22 | $this->app->singleton('hey_man_route_authorizer', RouteConditionApplier::class); |
||
23 | $this->app->singleton(YouShouldHave::class, YouShouldHave::class); |
||
24 | $this->app->singleton('hey_man_responder', Responder::class); |
||
25 | |||
26 | $this->mergeConfigFrom( |
||
27 | __DIR__.'/../config/heyMan.php', |
||
28 | 'heyMan' |
||
29 | ); |
||
30 | } |
||
31 | |||
32 | private function defineGates(): void |
||
33 | { |
||
34 | Gate::define('heyman.youShouldHaveRole', function ($user, $role) { |
||
35 | return $user->role == $role; |
||
36 | }); |
||
38 | } |