user->email); $sid = config('ninja.twilio_account_sid'); $token = config('ninja.twilio_auth_token'); if (!$sid) { return; } // no twilio api credentials provided, bail. $twilio = new \Twilio\Rest\Client($sid, $token); $country = $this->user->account?->companies()?->first()?->country(); if (!$country || strlen($this->user->phone) < 2) { return; } $countryCode = $country->iso_3166_2; try { $phone_number = $twilio->lookups->v1->phoneNumbers($this->user->phone) ->fetch(["countryCode" => $countryCode]); } catch(\Exception $e) { $this->user->verified_phone_number = false; $this->user->save(); return; } if ($phone_number && strlen($phone_number->phoneNumber) > 1) { $this->user->phone = $phone_number->phoneNumber; $this->user->verified_phone_number = true; $this->user->save(); } } }