BeatSwitch\Lock\Integrations\Laravel\LockServiceProvider::bootstrapAuthedUserLock PHP Method

bootstrapAuthedUserLock() protected method

This will bootstrap the lock instance for the authed user
protected bootstrapAuthedUserLock ( )
    protected function bootstrapAuthedUserLock()
    {
        $this->app->singleton(Lock::class, function ($app) {
            // If the user is logged in, we'll make the user lock aware and register its lock instance.
            if ($app['auth']->check()) {
                // Get the lock instance for the authed user.
                $lock = $app[Manager::class]->caller($app['auth']->user());
                // Enable the LockAware trait on the user.
                $app['auth']->user()->setLock($lock);
                return $lock;
            }
            // Get the caller type for the user caller.
            $userCallerType = $app['config']->get('lock.user_caller_type');
            // Bootstrap a SimpleCaller object which has the "guest" role.
            return $app[Manager::class]->caller(new SimpleCaller($userCallerType, 0, ['guest']));
        });
    }