From 61c1c2bef93dc24efad3d8c7ff5734990b996954 Mon Sep 17 00:00:00 2001 From: Mekan1206 Date: Tue, 19 May 2026 18:35:25 +0500 Subject: [PATCH] good so far --- .../Controllers/VerificationController.php | 35 +++++++++++++++---- app/Providers/AppServiceProvider.php | 2 +- config/app.php | 2 +- resources/views/layouts/app.blade.php | 6 ++-- .../verification/congratulations.blade.php | 18 +++++----- resources/views/verification/index.blade.php | 11 +++--- resources/views/verification/verify.blade.php | 31 ++++++++++------ routes/web.php | 1 + 8 files changed, 68 insertions(+), 38 deletions(-) diff --git a/app/Http/Controllers/VerificationController.php b/app/Http/Controllers/VerificationController.php index 44b6e68..baaf45b 100644 --- a/app/Http/Controllers/VerificationController.php +++ b/app/Http/Controllers/VerificationController.php @@ -20,7 +20,7 @@ class VerificationController extends Controller $request->validate([ 'phone' => ['required', 'regex:/^\+993 [67]\d \d{2} \d{2} \d{2}$/'] ], [ - 'phone.regex' => 'The phone number must be in the format: +993 KX XX XX XX (where K is 6 or 7).' + 'phone.regex' => 'Telefon belgiňiz şu formatda bolmaly: +993 KX XX XX XX (bu ýerde K 6 ýa-da 7).' ]); $phone = unmask_phone($request->phone); @@ -28,9 +28,6 @@ class VerificationController extends Controller // Generate a 4-digit OTP $otp = (string) rand(1000, 9999); - // Log it to simulate SMS - Log::info('Tassyklaýyş belgi: ' . $otp); - // Store in DB PhoneVerification::updateOrCreate( ['phone' => $phone], @@ -60,6 +57,32 @@ class VerificationController extends Controller ]); } + public function resendOtp() + { + $phone = session()->get('verify_phone'); + + if (!$phone) { + return redirect()->route('verification.index'); + } + + // Generate a 4-digit OTP + $otp = (string) rand(1000, 9999); + + // Store in DB + PhoneVerification::updateOrCreate( + ['phone' => $phone], + [ + 'otp' => $otp, + 'expires_at' => now()->addMinutes(10), + 'verified' => false + ] + ); + + sendSMS($phone, $otp); + + return back()->with('status', 'Täze kod iberildi!'); + } + public function verifyOtp(Request $request) { $request->validate([ @@ -70,11 +93,11 @@ class VerificationController extends Controller $verification = PhoneVerification::query()->where('phone', $request->phone)->first(); if (!$verification || $verification->otp !== $request->otp) { - return back()->withErrors(['otp' => 'Invalid OTP.']); + return back()->withErrors(['otp' => 'Nädogry kod.']); } if ($verification->expires_at < now()) { - return back()->withErrors(['otp' => 'OTP has expired.']); + return back()->withErrors(['otp' => 'Kodyň möhleti gutardy.']); } // Mark as verified diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 452e6b6..5905972 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -19,6 +19,6 @@ class AppServiceProvider extends ServiceProvider */ public function boot(): void { - // + app()->setLocale('tk'); } } diff --git a/config/app.php b/config/app.php index 423eed5..5ff548d 100644 --- a/config/app.php +++ b/config/app.php @@ -65,7 +65,7 @@ return [ | */ - 'timezone' => 'UTC', + 'timezone' => 'Asia/Ashgabat', /* |-------------------------------------------------------------------------- diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 1b0685b..6c9b186 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -1,9 +1,9 @@ - + - OTP Verification + OTP Tassyklamak @@ -120,7 +120,7 @@
@yield('header-back') -

Verification

+

Tassyklamak

diff --git a/resources/views/verification/congratulations.blade.php b/resources/views/verification/congratulations.blade.php index fceffca..57e87ff 100644 --- a/resources/views/verification/congratulations.blade.php +++ b/resources/views/verification/congratulations.blade.php @@ -48,20 +48,20 @@
-

Congratulations!

-

Your coupon code is ready to use.

+

Gutlaýarys!

+

Kupon koduňyz ulanmaga taýýar.

-
Limited Offer Code
+
Çäklendirilen Teklip Kody
{{ $code }}
@@ -71,10 +71,10 @@
- Back to Home + Baş sahypa dolan
@@ -82,7 +82,7 @@
info

- This coupon is valid for the next 24 hours only. Make sure to apply it during checkout to enjoy your discount. + Bu kupon diňe öňümizdäki 24 sagadyň dowamynda hereket edýär. Arzanladyşdan peýdalanmak üçin töleg wagtynda ulanmagy ýatdan çykarmaň.

@@ -153,11 +153,11 @@ const btnText = document.getElementById('copyText'); const btnIcon = document.getElementById('copyIcon'); - btnText.innerText = 'Copied!'; + btnText.innerText = 'Göçürildi!'; btnIcon.innerText = 'check'; setTimeout(() => { - btnText.innerText = 'Copy Code'; + btnText.innerText = 'Kody göçür'; btnIcon.innerText = 'content_copy'; }, 2000); } diff --git a/resources/views/verification/index.blade.php b/resources/views/verification/index.blade.php index 0032c1b..bc6c6a4 100644 --- a/resources/views/verification/index.blade.php +++ b/resources/views/verification/index.blade.php @@ -26,8 +26,8 @@
-

Enter your phone number

-

We'll send a 4-digit code to verify your account.

+

Telefon belgiňizi giriziň

+

Hasabyňyzy tassyklamak üçin 4 sanly kod ibereris.

@@ -52,7 +52,7 @@
info

- Message and data rates may apply. You will receive one SMS code for verification purposes. + Tassyklaýyş maksady bilen size bir SMS kod iberiler.

@@ -60,10 +60,7 @@
-
diff --git a/resources/views/verification/verify.blade.php b/resources/views/verification/verify.blade.php index 0c845ae..4167658 100644 --- a/resources/views/verification/verify.blade.php +++ b/resources/views/verification/verify.blade.php @@ -31,9 +31,9 @@
app_registration
-

Verify your number

+

Belgiňizi tassyklaň

- Enter the 4-digit code sent to {{ $phone }} + Şu belgä iberilen 4 sanly kody giriziň: +933 {{ $phone }}

@@ -43,6 +43,12 @@ @endif + @if (session('status')) +
+ {{ session('status') }} +
+ @endif +
@csrf @@ -59,22 +65,25 @@
-
- -
+
+
+ @csrf + +
+
info

- We use this to keep your account secure. Your number will not be shared with others. + Muny hasabyňyzyň howpsuzlygyny üpjün etmek üçin ulanýarys. Belgiňiz başgalar bilen paýlaşylmaz.

@@ -108,13 +117,13 @@ if (code.length === 4) { hiddenOtp.value = code; - verifyBtn.innerHTML = ' Verifying...'; + verifyBtn.innerHTML = ' Tassyklanýar...'; setTimeout(() => { form.submit(); }, 500); // small delay to show animation } else { - alert('Please enter a 4-digit code.'); + alert('Haýyş, 4 sanly kody giriziň.'); } }); diff --git a/routes/web.php b/routes/web.php index 3c370c6..f1f580d 100644 --- a/routes/web.php +++ b/routes/web.php @@ -7,4 +7,5 @@ Route::get('/', [VerificationController::class, 'index'])->name('verification.in Route::post('/send-otp', [VerificationController::class, 'sendOtp'])->name('verification.send'); Route::get('/verify', [VerificationController::class, 'verifyForm'])->name('verification.verify.form'); Route::post('/verify', [VerificationController::class, 'verifyOtp'])->name('verification.verify'); +Route::post('/resend-otp', [VerificationController::class, 'resendOtp'])->name('verification.resend'); Route::get('/congratulations', [VerificationController::class, 'congratulations'])->name('verification.congratulations');