php – Response: 500 – Call to a member function update() on null

Estou tendo esse problema ao tentar usar o registro no api da Uppo.

<?php

namespace AppApiV2ControllersAuth;

use AppApiV2ModelsUser;
use AppApiV2ModelsBenefit;
use AppApiV2NotificationsSendResetPasswordLinkNotification;
use AppApiV2NotificationsWelcomeNotification;
use AppApiV2RepositoriesClubClubRepository;
use AppApiV2RepositoriesBenefitBenefitRepository;
use AppApiV2RepositoriesInviteInviteRepository;
use AppApiV2RepositoriesSocialSocialRepository;
use AppApiV2RepositoriesUserUserRepository;
use AppApiV2ResourcesUserPublicResource;
use AppApiV2RulesInvitableRule;
use AppApiV2RulesSecretRule;
use DingoApiExceptionStoreResourceFailedException;
use DingoApiExceptionValidationHttpException;
use IlluminateValidationUnauthorizedException;
use AppApiV2ModelsDeviceToken;
use Validator;
use IlluminateHttpRequest;
use TymonJWTAuthJWTAuth;
use AppHttpControllersController;
use DB;
use Mail;
use oliveready7LaravelSesSesMail;
use AppApiV2UtilsEmailVerificationStatus;
use GuzzleHttpClient as GuzzleClient;
use AppApiV2ModelsSettings;
use AppApiV2ModelsUserSubscription;
use AppApiV2LibrariesCheckSubscriptionStatus;

class RegisterController extends Controller
{
    protected $userRepository;
    protected $jwtAuth;
    protected $inviteRepository;
    protected $clubRepository;
    protected $socialRepository;
    protected $benefitRepository;

    function __construct(
        UserRepository $userRepository,
        JWTAuth $jwtAuth,
        InviteRepository $inviteRepository,
        ClubRepository $clubRepository,
        SocialRepository $socialRepository,
        BenefitRepository $benefitRepository
    )
    {
        $this->userRepository = $userRepository;
        $this->jwtAuth = $jwtAuth;
        $this->inviteRepository = $inviteRepository;
        $this->clubRepository = $clubRepository;
        $this->socialRepository = $socialRepository;
        $this->benefitRepository = $benefitRepository;
    }

    public function register(Request $request)
    {
        $data = $request->except('type');
        use Request;
        
        $emailVerificationStatus = new EmailVerificationStatus();
        $club = $this->clubRepository->getPublicSimpleInfo($request->route('slug'));
        if (!$club) {
            throw new ResourceNotFoundException('Club not found.');
        }
        // $club->image = $club->logo->url;
        // $club->logoUrl = $club->logo->url;
        $url = env('APP_URL') . $club->slug;

        if ($club->integration) {
            unset($data('code'));
        }

        if($club->slug == 'union'){
            $validator = $this->userRepository->validateCreateForUnion($data);
        }else if($club->slug == 'plusclubedevantagens' || $club->slug == 'clubegaruper'){
            $validator = $this->userRepository->validateCreateForPlusclubedevantagens($data);
        }else if($club->slug == 'powerbeneficios'){
            $validator = $this->userRepository->validateCreateForPowerbeneficios($data);
        }else{
            $validator = $this->userRepository->validateCreate($data);
        }

        if(isset($data('code'))){
            if($club->slug == 'clubefacility' || $club->slug == 'plusclubedevantagens' || $club->slug == 'clubegaruper'){
                $data('cpf') = $data('code');
            }
        }
        
        if ($validator->fails()) {
            throw new ValidationHttpException($validator->errors()->toArray());
        }

        /** @var User $user */
        // if (!$user = $this->userRepository->create($request->except('type'))) {
        $data('email_verification_token') = str_random(25);
        // $data('email_verification_status') = EmailVerificationStatus::Email_Verification_Pending;
        $data('email_verification_status') = EmailVerificationStatus::Email_Verfied;
        $userData = User::where('email',$data('email'))->first(); 
        if(!$userData){
            if (!$user = $this->userRepository->create($data)) {
                throw new StoreResourceFailedException('Could not create the user.');
            }
        }else{
            $userData->name = $data('name');
            $userData->email = $data('email');
            $userData->password = $data('password');
            $userData->login_type = $data('login_type');
            $userData->folha_access_token = $data('folha_access_token');
            $userData->expires_in = $data('expires_in');
            $userData->refresh_token = $data('refresh_token');
            $userData->save();
            $user = $userData;
        }
        $user = User::where('email',$data('email'))->first();
        if($request->route('slug') != 'powerbeneficios' && $request->route('slug') != 'rebeneficios'){
            if ($request->code && $club->auth === 'code' && $club->code != 'cnpj') {
                $this->inviteRepository->useOne($request->all());
             }
        }
        

        if ($request->social && $request->provider) {
            $socialData = (
                'provider' => $request->provider,
                'value' => $request->social,
                'user_id' => $user->id,
                'club_id' => $request->club_id
            );
            $this->socialRepository->create($socialData);
        }

        $token = $this->jwtAuth->fromUser($user);
        // $verification_link = env('APP_URL').$club->slug.'/verify-email/'.$user->email_verification_token;
        // Session::put('club_id',$club->id);
        // SesMail::enableAllTracking()->setBatch('Email de verificação do usuário')->send('emails.verify_email', ('user' => $user, 'club' => $club, 'verification_link' => $verification_link), function ($m) use($user, $club) {
        //     $m->from(env('MAIL_NO_REPLY'));
        //     $m->to($user->email)->subject("$club->name - Verifique seu e-mail para concluir o cadastro!");
        // });

        // $user->notify(new WelcomeNotification());
        
        // For Welcome Email
        $isEmailValid = $emailVerificationStatus->EmailValidityIntegration($user->email);
        if(!!$isEmailValid && $club->email_auto != 1){
            Session::put('club_id',$club->id);
            Mail::send('emails.welcome-notification', ('club' => $club,'url'=>$url), function ($m) use ($club,$user)
            {
                $m->from(env('MAIL_NO_REPLY'),$club->name);
                $m->to($user->email)->subject('('.$club->name.') - Bem-vindo!');
            });
            // SesMail::enableAllTracking()->setBatch('E-mail de boas-vindas')->send('emails.welcome-notification', ('club' => $club,'url'=>$url), function ($m) use ($club,$user)
            // {
            //     $m->from(env('MAIL_NO_REPLY'));
            //     $m->to($user->email)->subject('('.$club->name.') - Bem-vindo!');
            // });
        }

        if($request->route('slug') === 'vitrineconecta') { //For vitrineconecta only
            $cities = $this->benefitRepository->getBenefitsCitiesByClub($club->id);     
            $data ('cities') = $cities;
        }
        
        if(!array_key_exists('device_type',$data)){
            $data('device_type') = "";   
        }
        if(!array_key_exists('device_token',$data)){
            $data('device_token') = "";   
        }
        $deviceTokenData = (
            'club_id' => $data('club_id'),
            'user_id' => $user->id,
            'device_type' => $data('device_type'), 
            'device_token' => $data('device_token') 
        );
        if($user->type == 'admin'){
            $deviceTokenData('user_type') = 1;
        }else{
            $deviceTokenData('user_type') = 2;
        }
        if($data('device_type') != '' && $data('device_token') != ''){
            $deviceToken = DeviceToken::where('user_id',$deviceTokenData('user_id'))->where('club_id',$deviceTokenData('club_id'))->where('device_token',$deviceTokenData('device_token'))->first();
            if($deviceToken){
                $deviceToken->delete();
            }
            DeviceToken::create($deviceTokenData);
        }
        $data('access_token') = $token;
        $userData = new PublicResource($user);
        $checkstatus = new CheckSubscriptionStatus();
        $subscriptionStatus = $checkstatus->checkSubscriptionStatus($club->id,$userData->id);
        // $subscriptionStatus = $this->checkSubscriptionStatus($club->id,$userData->id);
        $data('subscription') = $subscriptionStatus;
        $data('user') = $userData;
        
        return response()
            ->json((
                'success' => true,
                'data' => $data
            ), 201);

    }
    
    // public function checkSubscriptionStatus($club_id,$user_id)
    // {
    //     $subscriptionDataGet = UserSubscription::where('user_id',$user_id)->where('club_id',$club_id)->first();
    //     if($subscriptionDataGet){
    //         $params('packageName') = $subscriptionDataGet->package_name;
    //         $params('productId') = $subscriptionDataGet->product_id;
    //         $params('purchaseToken') = $subscriptionDataGet->purchase_token;
    //         $setting = Settings::first();
    //         $currentTime = strtotime(date('Y-m-d H:i:s'));
    //         if($setting){
    //             if($setting->expiry_time < $currentTime){
    //                 $refreshToken = $this->refreshAccessToken();
    //             }else{
    //                 $refreshToken('access_token') = $setting->access_token;
    //             }
    //         }else{
    //             $refreshToken = $this->refreshAccessToken();
    //         }
    //         $client = new GuzzleClient();
    //         $response = $client->get("https://www.googleapis.com/androidpublisher/v3/applications/".$params('packageName')."/purchases/subscriptions/".$params('productId')."/tokens/".$params('purchaseToken')."?access_token=".$refreshToken('access_token'));
    //         $response = json_decode($response->getBody(),true);
    //         if(strtotime(date('Y-m-d H:i:s')) > $response('expiryTimeMillis')){
    //             return false;
    //         }else{
    //             return true;
    //         }
    //     }else{
    //         return false;
    //     }
        
    // }

    public function refreshAccessToken()
    {
        $client = new GuzzleClient();
        $response = $client->post("https://accounts.google.com/o/oauth2/token", (
            'form_params' => (
                'grant_type' => 'refresh_token',
                'client_id' => env('GOOGLE_CLIENT_ID'),
                'client_secret' => env('GOOGLE_CLIENT_SECRET_KEY'),
                'refresh_token' => '1//0gz4mxgC29l7LCgYIARAAGBASNwF-L9Ir16-o9khFL_UtL7YYcRK_7nkBmAx2K6-RHpthKQ23atkvC0f01oxWxuCCL7KCe239QbQ'
            )
        ));
        $response = json_decode($response->getBody(),true);
        $setting = Settings::first();
        $currentTime = strtotime(date('Y-m-d H:i:s'));
        $expiry_time = $currentTime + $response('expires_in') - 10;
        if($setting){
            $setting->access_token = $response('access_token');
            $setting->expiry_time = $expiry_time;
            $setting->save();
        }else{
            $data = (
                'access_token' =>  $response('access_token'),
                'refresh_token' =>  '1//0gz4mxgC29l7LCgYIARAAGBASNwF-L9Ir16-o9khFL_UtL7YYcRK_7nkBmAx2K6-RHpthKQ23atkvC0f01oxWxuCCL7KCe239QbQ',
                'expiry_time' =>    $expiry_time
            );
            Settings::Create($data);
        }
        return $response;
    }
    /**
     * Validate Register fields
     *
     * @param Request $request
     * @return IlluminateHttpJsonResponse
     */
    public function validateRegisterFields(Request $request)
    {
        
        if($request->route('slug') == 'clubsaude'){
            // for club clubsaude
            // third party api call for club 
            $curl = curl_init();
            curl_setopt_array($curl, array(
                CURLOPT_URL => "https://clubsaude.nvstec.com/wscrm/Associado/GET_STATUS_ASSOCIADO?cpf=".$request->get('code'),
                CURLOPT_RETURNTRANSFER => true,
                CURLOPT_ENCODING => "",
                CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            ));
            $response = json_decode(curl_exec($curl));
            if($response->status == "Ativo"){
                $cpfData = array('cpf'=>$request->get('code'));
                $validator = $this->userRepository->validateCpfExist($cpfData);
                if ($validator->fails()) {
                    throw new UnauthorizedException('Erro: CPF já existe.');
                }
                return response()->json((
                    'success' => true,
                ), 201);
            }else{
                throw new UnauthorizedException('Erro: CPF não autorizado.');
            }
        }else{
            // for rest of all clubs
            if ($integration = getIntegration($request->route('slug'), 'validateRegisterFields')) {
                return $integration->validateRegisterFields($request);
            }
            $club = $this->clubRepository->findByField('slug', $request->route('slug'))->first();
            $validation = (
                'code' => ('required', new InvitableRule()),
            );

            if ($club->auth === 'secret') {
                $validation = (
                    'code' => ('required', new SecretRule()),
                );
            }

            $validator = Validator::make($request->all(), $validation);

            if ($validator->fails()) {
                throw new ValidationHttpException($validator->errors()->toArray());
            }

            return response()->json((
                'success' => true,
            ), 201);
        }
    }
}

Aonde a request para

Erro no register