src/Gzero/Repository/SocialRepository.php
public function createNewUser($serviceName, AbstractUser $response)
    {
        $data         = $this->parseServiceResponse($response);
        $existingUser = $this->userRepo->getByEmail($data['email']);
        // duplicated user verification
        if ($existingUser === null) {
            $data['password'] = str_random(40);
            $user = $this->userRepo->create($data);
            // create relation for new user and social integration
            $this->addSocialRelation($user, $serviceName, $response);
            return $user;
        } else {
            session()->put('url.intended', route('register'));
            throw new SocialException(
                trans('gzero-social::common.email_already_in_use_message', ['service_name' => title_case($serviceName)])
            );
        }
    }
public function createNewUser($serviceName, AbstractUser $response)
    {
        $data         = $this->parseServiceResponse($response);
        $existingUser = $this->userRepo->getByEmail($data['email']);
        // duplicated user verification
        if ($existingUser === null) {
            $data['password'] = str_random(40);
            $user = $this->userRepo->create($data);
            // create relation for new user and social integration
            $this->addSocialRelation($user, $serviceName, $response);
            return $user;
        } else {
            session()->put('url.intended', route('register'));
            throw new SocialException(
                trans('gzero-social::common.email_already_in_use_message', ['service_name' => title_case($serviceName)])
            );
        }
    }
public function createNewUser ( $ serviceName , AbstractUser $ response ) { $ data = $ this -> parseServiceResponse ( $ response ) ; $ existingUser = $ this -> userRepo -> getByEmail ( $ data [ 'email' ] ) ; // duplicated user verification if ( $ existingUser === null ) { $ data [ 'password' ] = str_random ( 40 ) ; $ user = $ this -> userRepo -> create ( $ data ) ; // create relation for new user and social integration $ this -> addSocialRelation ( $ user , $ serviceName , $ response ) ; return $ user ; } else { session ( ) -> put ( 'url.intended' , route ( 'register' ) ) ; throw new SocialException ( trans ( 'gzero-social::common.email_already_in_use_message' , [ 'service_name' => title_case ( $ serviceName ) ] ) ) ; } }
Function creates new user based on social service response and create relation with social integration in database.

@param $serviceName    string name of social service
@param $response       AbstractUser response data

@return User
@throws SocialException
Function creates new user based on social service response and create relation with social integration in database .