protected function insertToken(?Authenticatable $user, string $token, string $email) : Token
    {
        if ($user === null) {
            throw new NullValueException("User cannot be null");
        }

        /** @var \Laranix\Auth\User\Token\Token $row */
        $row = $this->getModel()
                    ->updateOrCreateNew([
                        'user_id'   => $user->getAuthIdentifier(),
                        'email'     => $email,
                        'token'     => $token,
                    ], 'user_id');

        if ($row->wasRecentlyCreated) {
            $this->fireCreatedEvent($user, $row);
        } else {
            $this->fireUpdatedEvent($user, $row);
        }

        return $row;
    }
protected function insertToken(?Authenticatable $user, string $token, string $email) : Token
    {
        if ($user === null) {
            throw new NullValueException("User cannot be null");
        }

        /** @var \Laranix\Auth\User\Token\Token $row */
        $row = $this->getModel()
                    ->updateOrCreateNew([
                        'user_id'   => $user->getAuthIdentifier(),
                        'email'     => $email,
                        'token'     => $token,
                    ], 'user_id');

        if ($row->wasRecentlyCreated) {
            $this->fireCreatedEvent($user, $row);
        } else {
            $this->fireUpdatedEvent($user, $row);
        }

        return $row;
    }
protected function insertToken ( ? Authenticatable $ user , string $ token , string $ email ) : Token { if ( $ user === null ) { throw new NullValueException ( "User cannot be null" ) ; } /** @var \Laranix\Auth\User\Token\Token $row */ $ row = $ this -> getModel ( ) -> updateOrCreateNew ( [ 'user_id' => $ user -> getAuthIdentifier ( ) , 'email' => $ email , 'token' => $ token , ] , 'user_id' ) ; if ( $ row -> wasRecentlyCreated ) { $ this -> fireCreatedEvent ( $ user , $ row ) ; } else { $ this -> fireUpdatedEvent ( $ user , $ row ) ; } return $ row ; }
Insert a token

@param \Illuminate\Contracts\Auth\Authenticatable|User $user
@param string                                          $token
@param string                                          $email
@return \Laranix\Auth\User\Token\Token
@throws \Laranix\Support\Exception\NullValueException
Insert a token