sms and update admin

changes
This commit is contained in:
2026-06-12 12:57:23 +05:45
parent 3b529327bf
commit 85e87beaf6
8 changed files with 519 additions and 13 deletions
@@ -8,6 +8,8 @@ use App\Models\GameShot;
use App\Models\Registration;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Mail;
class RegistrationController extends Controller
{
@@ -64,6 +66,15 @@ class RegistrationController extends Controller
'score' => 0,
]);
if ($request->filled('email')) {
dispatch(function () use ($registration) {
Mail::send('emails.welcome', ['registration' => $registration], function ($message) use ($registration) {
$message->to($registration->email)
->subject('Welcome to the Score & Win Challenge 2026! ⚽');
});
})->afterResponse();
}
return response()->json([
'status' => 'session_created',
'registration' => [
@@ -95,9 +106,11 @@ class RegistrationController extends Controller
Cache::put("otp_$phone", $otp, now()->addMinutes(2));
sendSMS($phone, "Your OTP for Score & Win Challenge 2026 is: $otp. It is valid for 2 minutes.");
return response()->json([
'status' => true,
'otp' => $otp // remove in production
// 'otp' => $otp // remove in production
]);
}
@@ -263,6 +276,16 @@ class RegistrationController extends Controller
$registration = $session->registration;
$registration->update(['total_score' => $registration->sessions()->sum('score')]);
if ($registration->email && $request->shot_number == 3) {
dispatch(function () use ($registration) {
Mail::send('emails.score', ['registration' => $registration], function ($message) use ($registration) {
$message->to($registration->email)
->subject('Your Score Update for the Score & Win Challenge 2026! ⚽');
});
})->afterResponse();
}
return response()->json([
'status' => 'ok',
'total_score' => $registration->fresh()->total_score,