public function createToken($name, array $scopes = [])
    {
        // Backup default provider
        $defaultProvider = config('auth.guards.api.provider');

        $userProvider = AuthConfigHelper::getUserProvider($this);

        // Change config to when the token is created set the provider from model creating the token.
        config(['auth.guards.api.provider' => $userProvider]);

        $token = Container::getInstance()->make(PersonalAccessTokenFactory::class)->make(
            $this->getKey(), $name, $scopes
        );

        // Reset config to defaults
        config(['auth.guards.api.provider' => $defaultProvider]);

        return $token;
    }
public function createToken($name, array $scopes = [])
    {
        // Backup default provider
        $defaultProvider = config('auth.guards.api.provider');

        $userProvider = AuthConfigHelper::getUserProvider($this);

        // Change config to when the token is created set the provider from model creating the token.
        config(['auth.guards.api.provider' => $userProvider]);

        $token = Container::getInstance()->make(PersonalAccessTokenFactory::class)->make(
            $this->getKey(), $name, $scopes
        );

        // Reset config to defaults
        config(['auth.guards.api.provider' => $defaultProvider]);

        return $token;
    }
public function createToken ( $ name , array $ scopes = [ ] ) { // Backup default provider $ defaultProvider = config ( 'auth.guards.api.provider' ) ; $ userProvider = AuthConfigHelper :: getUserProvider ( $ this ) ; // Change config to when the token is created set the provider from model creating the token. config ( [ 'auth.guards.api.provider' => $ userProvider ] ) ; $ token = Container :: getInstance ( ) -> make ( PersonalAccessTokenFactory :: class ) -> make ( $ this -> getKey ( ) , $ name , $ scopes ) ; // Reset config to defaults config ( [ 'auth.guards.api.provider' => $ defaultProvider ] ) ; return $ token ; }
Create a new personal access token for the user and create .

@param  string $name
@param  array $scopes
@return PersonalAccessTokenResult
@throws MissingConfigException
Create a new personal access token for the user and create .