public function boot() { Gate::policy(Request::class, RequestPolicy::class); foreach (AppServiceProvider::getObjectModelNames() as $model) { $modelClass = 'CHMS\\ProviderHub\\Models\\' . $model; $policyClass = 'CHMS\\ProviderHub\\Policies\\' . $model; Gate::policy($modelClass, $policyClass); } }
/** * @inheritdoc */ public function register() { $localModels = AppServiceProvider::getObjectModelNames(); foreach ($localModels as $model) { $modelClass = 'CHMS\\ProviderHub\\Models\\' . $model; $contractClass = 'CHMS\\ProviderHub\\Repositories\\' . $model . '\\Contract'; $repositoryClass = 'CHMS\\ProviderHub\\Repositories\\' . $model . '\\Provider'; $this->app->bind($contractClass, function ($app) use($modelClass, $repositoryClass) { return new $repositoryClass(new $modelClass()); }); } }
/** * Boot the authentication services for the application. * * @return void */ public function boot() { $app = $this->app; Auth::extend('oauth', function ($app, $name, array $config) { $guard = new OAuthGuard($name, Auth::createUserProvider($config['provider']), $app['request'], $config); $app->refresh('request', $guard, 'setRequest'); return $guard; }); Auth::provider('hubAuthProvider', function ($app, array $config) { return new ClientUserProvider($app['hash'], $config['model']); }); $this->app->singleton('authorizer', function ($app) { $app->configure('authorizer'); $authorizer = new ProxyAuthorizer($app, config('authorizer')); return $authorizer; }); $this->app->singleton(AclContract::class, function ($app) { $app->configure('acl'); $acl = new Acl($app, config('acl')); return $acl; }); $this->app->singleton('context', function ($app) { return new Context(); }); $this->app->singleton(InputGateContract::class, function ($app) { $gate = new InputGate($app); foreach (AppServiceProvider::getObjectModelNames() as $model) { $modelClass = 'CHMS\\ProviderHub\\Models\\' . $model; $filterClass = 'CHMS\\ProviderHub\\Http\\Input\\Filters\\' . $model; $gate->filter($modelClass, $filterClass); } foreach (AppServiceProvider::getObjectModelNames() as $model) { $modelClass = 'CHMS\\ProviderHub\\Models\\' . $model; $validatorClass = 'CHMS\\ProviderHub\\Http\\Input\\Validators\\' . $model; $gate->validator($modelClass, $validatorClass); } return $gate; }); }