Bristol SU Support Package
UserServiceProvider.php
Go to the documentation of this file.
1 <?php
2 
3 namespace BristolSU\Support\User;
4 
6 use BristolSU\Support\User\Contracts\UserRepository as UserRepositoryContract;
9 
13 class UserServiceProvider extends ServiceProvider
14 {
15 
22  public function register()
23  {
24  $this->app->call([$this, 'registerUserAuthentication']);
25  $this->app->bind(UserRepositoryContract::class, UserRepository::class);
26  }
27 
34  public function registerUserAuthentication(Request $request)
35  {
36  $this->app->bind(UserAuthentication::class, function($app) use ($request) {
37  return ($request->is('api/*') ?
38  $app->make(UserApiAuthentication::class) : $app->make(UserWebAuthentication::class));
39  });
40  }
41 
47  public function boot()
48  {
49  $this->app['auth']->resolveUsersUsing(function() {
50  return app()->make(UserAuthentication::class)->getUser();
51  });
52  }
53 
54 
55 }