diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php new file mode 100644 index 0000000..aae7526 --- /dev/null +++ b/app/Helpers/Helper.php @@ -0,0 +1,35 @@ + $key, + 'contacts' => $destination, + 'senderid' => $sender, + 'msg' => $message, + 'responsetype' => 'json', + ]); + + $separator = parse_url($url, PHP_URL_QUERY) ? '&' : '?'; + $url_final = $url . $separator . $params; + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url_final); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_TIMEOUT, 30); + $response = curl_exec($ch); + $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + curl_close($ch); + + if ($response === false || $httpCode >= 400) { + return false; + } + + return true; + } +} diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index d52156f..06fc5c4 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -71,6 +71,7 @@ class HomeController extends Controller $data['registrations'] = $query; $data['search'] = $search; $data['total'] = Registration::count(); + $data['todayTotal'] = $query->total(); $data['played'] = $registrations->filter(fn($r) => !empty($r['today_goals']) && count($r['today_goals']) >= 3)->count(); $data['topScore'] = $registrations->max('total_score') ?? 0; $data['countries'] = Country::where('status', 1)->orderBy('title')->get(['id','title','country_flag']); diff --git a/app/Http/Controllers/RegistrationController.php b/app/Http/Controllers/RegistrationController.php index 8e486a4..172eb9b 100644 --- a/app/Http/Controllers/RegistrationController.php +++ b/app/Http/Controllers/RegistrationController.php @@ -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, diff --git a/composer.json b/composer.json index 9f450d8..b2def86 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,10 @@ "App\\": "app/", "Database\\Factories\\": "database/factories/", "Database\\Seeders\\": "database/seeders/" - } + }, + "files": [ + "app/Helpers/Helper.php" + ] }, "autoload-dev": { "psr-4": { diff --git a/resources/views/dashboard/admin.blade.php b/resources/views/dashboard/admin.blade.php index 58db977..f91ce62 100644 --- a/resources/views/dashboard/admin.blade.php +++ b/resources/views/dashboard/admin.blade.php @@ -97,7 +97,7 @@ Today's Sessions - {{ $total }} students + {{ $todayTotal }} students @@ -178,7 +178,7 @@
-

Showing {{ $total }} students

+

Showing {{ $todayTotal }} students

@@ -293,10 +293,10 @@ - --}} { document.getElementById('phoneSentTo').textContent = phone; - if (res.otp) { - document.getElementById('otpPreview').classList.remove('hidden'); - document.getElementById('otpValue').textContent = res.otp; - } + // if (res.otp) { + // document.getElementById('otpPreview').classList.remove('hidden'); + // document.getElementById('otpValue').textContent = res.otp; + // } goToStep(2); }) .fail(() => showError('Failed to send OTP. Please try again.')) diff --git a/resources/views/emails/score.blade.php b/resources/views/emails/score.blade.php new file mode 100644 index 0000000..5a65b16 --- /dev/null +++ b/resources/views/emails/score.blade.php @@ -0,0 +1,233 @@ + + + + + +Keep Climbing the Leaderboard! + + + + + + +
+ +
+ +
+

Score & Win Challenge

+
+
+ Rosetta Education International +
+ +
+ +
+ +
+ Hi {{ $registration->name }}, +
+ +

+ Thank you for participating in today's Score & Win Challenge at Rosetta Education Consultancy! +

+ +
+
Your Current Score
+
{{ $registration->total_score}} Points
+
+ +

+ Great job! Every point counts, and the competition is just getting started. +

+ +

+ Remember, you can return tomorrow and play again to improve your score and climb higher on the leaderboard. +

+ +

+ The participant with the highest score at the end of the campaign will be crowned the Ultimate Winner and receive exciting prizes and rewards. +

+ +

+ The more days you play, the better your chances of winning. +

+ + +
+

While You're Here, Explore Your Study Abroad Opportunities

+ +
    +
  • Free education counseling & career guidance
  • +
  • Study destination support – UK, Australia, Canada & USA
  • +
  • University selection tailored to your profile
  • +
  • SOP (Statement of Purpose) preparation
  • +
  • Scholarship assistance
  • +
  • Admission processing & documentation support +
  • +
  • Student visa guidance
  • +
  • IELTS & PTE preparation classes
  • +
+
+ +

+ We look forward to seeing you again tomorrow. Keep playing, keep scoring, and keep moving closer to your dream destination. +

+ +
+
+ +

+ Best Regards, +

+ + Rosetta Education International + +

+ Rosetta Education International +

+ +

+ Your Trusted Study Abroad Partner +

+ +

+ 📧 info@rosettaeducation.com +

+ +

+ 📞 +977-1-4560413 +

+ +

+ 🌐 https://rosettaeducation.com/ +

+ + + +
+
+ + + \ No newline at end of file diff --git a/resources/views/emails/welcome.blade.php b/resources/views/emails/welcome.blade.php new file mode 100644 index 0000000..e7a08df --- /dev/null +++ b/resources/views/emails/welcome.blade.php @@ -0,0 +1,211 @@ + + + + + +Welcome to Score & Win + + + + + + +
+ +
+ +
+

Welcome to Score & Win

+
+
+ Rosetta Education International +
+
+ +

Hi {{$registration->name}},

+ +

+ Welcome to the exciting Score & Win Challenge by Rosetta Education Consultancy. +

+ +
+ Your registration has been successfully completed. +

+ You're now officially part of the competition and eligible to compete for exciting prizes. +
+ +

+ Here's how it works: +

+ +
    +
  • Free education counseling & career guidance
  • +
  • Study destination support – UK, Australia, Canada & USA
  • +
  • University selection tailored to your profile
  • +
  • SOP (Statement of Purpose) preparation
  • +
  • Scholarship assistance
  • +
  • Admission processing & documentation support +
  • +
  • Student visa guidance
  • +
  • IELTS & PTE preparation classes
  • +
+ +

+ Consistent participation increases your chances of securing a top position and winning amazing rewards. +

+ + + +
+

Why Students Choose Rosetta Education Consultancy

+ +
    +
  • Expert Study Abroad Counseling
  • +
  • University Application Assistance
  • +
  • Scholarship & Financial Guidance
  • +
  • Visa Processing Support
  • +
  • Career-Oriented Course Selection
  • +
  • End-to-End Student Assistance
  • +
+
+ +

+ While you're competing for prizes, don't forget that our team is here to help you achieve your international education goals. +

+ +

+ Best of luck, and let the challenge begin! +

+ +
+
+ +

+ Best Regards, +

+ + Rosetta Education International + +

+ Rosetta Education International +

+ +

+ Your Trusted Study Abroad Partner +

+ +

+ 📧 info@rosettaeducation.com +

+ +

+ 📞 +977-1-4560413 +

+ +

+ 🌐 https://rosettaeducation.com/ +

+ + + +
+ + + +
+
+ + + \ No newline at end of file diff --git a/resources/views/scoreboard.blade.php b/resources/views/scoreboard.blade.php index 2cbbaf8..60c1cc9 100644 --- a/resources/views/scoreboard.blade.php +++ b/resources/views/scoreboard.blade.php @@ -295,7 +295,7 @@ } p.shots.forEach((result, i) => { - if (lastShots[i] === undefined) renderShot(i, result); + if (lastShots[i] === undefined || lastShots[i] !== result) renderShot(i, result); }); lastShots = [...p.shots];