Spaces:
Running
Running
File size: 608 Bytes
907b200 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <?php
namespace App\Helpers;
use App\Models\User;
use App\Services\OtpService;
class OtpHelper
{
/**
* Send OTP by type for a user email
*
* @param string $email
* @param string $type ('email_verification' or 'password_reset')
* @param OtpService $otpService
* @return array
*/
public static function sendOtpByType(string $email, string $type, OtpService $otpService): array
{
$user = User::where('email', $email)->firstOrFail();
$otpService->resendOtp($user, $type);
return [
'email' => $user->email
];
}
}
|