This is the code I have right now. I haven't tested it out yet but it looks like it's going to work? lol
RegisterController.php
protected function create(array $data)
{
$user = User::create([
'first_name' => $data['first_name'],
'last_name' => $data['last_name'],
'mobile_number' => $data['mobile_number'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
'authentication_code' => $this->generateAuthCode()
]);
$textMessage = new SmsController($user->mobile_number, $user->authentication_code);
$result = $textMessage->sendAuthCode();
if ($result ) {
// success
} else {
// error
}
return $user;
}
SmsController.php
public function __construct($number, $message) {
$this->number = $number;
$this->message = $message;
}
public function sendAuthCode()
{
$postData = array(
'1' => $this->number,
'2' => $this->message,
'3' => $this->apicode
);
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $this->url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query($postData)
));
// curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
// curl_setopt($ch, CURLOPT_SSL_VERIFYUSER, 0);
return curl_exec($ch);
curl_close($ch);
}