From baf23d4124ce882894316522c653ef9c497c6711 Mon Sep 17 00:00:00 2001 From: Nurmuhammet Allanov Date: Mon, 22 Sep 2025 16:50:01 +0500 Subject: [PATCH] Update user registration email format, remove unused SMS helper function, and adjust database migration for user meta column --- app/.DS_Store | Bin 6148 -> 6148 bytes app/Filament/Pages/Auth/Register.php | 2 +- app/Helpers/helpers.php | 28 ---------- app/Modules/.DS_Store | Bin 6148 -> 6148 bytes .../Controllers/OTPVerificationController.php | 49 ++++++++++++++++++ ...64249_create_o_t_p_verifications_table.php | 29 +++++++++++ .../Models/OTPVerification.php | 25 +++++++++ .../OTPVerification/OTPVerificationModule.php | 48 +++++++++++++++++ .../OTPVerificationRepository.php | 27 ++++++++++ .../SMS/Repositories/SMSRepository.php | 36 +++++++++++++ app/Modules/SMS/SMSModule.php | 48 +++++++++++++++++ ...62906_add_extra_columns_to_users_table.php | 2 +- 12 files changed, 264 insertions(+), 30 deletions(-) create mode 100644 app/Modules/OTPVerification/Controllers/OTPVerificationController.php create mode 100644 app/Modules/OTPVerification/Database/Migrations/2025_09_22_164249_create_o_t_p_verifications_table.php create mode 100644 app/Modules/OTPVerification/Models/OTPVerification.php create mode 100644 app/Modules/OTPVerification/OTPVerificationModule.php create mode 100644 app/Modules/OTPVerification/Repositories/OTPVerificationRepository.php create mode 100644 app/Modules/SMS/Repositories/SMSRepository.php create mode 100644 app/Modules/SMS/SMSModule.php diff --git a/app/.DS_Store b/app/.DS_Store index a19d0e0c52e56e2212ce06d00809bc4a4ec4ad5a..1e06f7828cc12ffb8965ef8ab1d7ef9d38a7ca9d 100644 GIT binary patch delta 551 zcmZoMXfc=|#>B!ku~2NHo+2aj#DLw41(=u_nJ4owzNpVkE-OgN$xmWnU_6^tkds+l zVqkDzK!A~nnT3^&or9B$n}?T=UqDbuSWrYzR8&k{LR3;pQYKzNI4LnXJH05sG%v+D zKPSJ)DW^0wI=v_}CAc6lIWsRkq9nDVBsjAwHC{jnO=(bSN*q+E9;iK}vH++^1Wl29 zQEF-)*g*fZwBpo~2qbo7ya0c3a#4OxPC$NfW=Up#USv#hMt-?xNouZVURplT%CgMV za{mI5RB>2pQ8AFl&=V1xlUSdWn&Y46lwVSkpBtH2RFs&Pp6XNyQVKFIIX^F;C>3N> zL?)08@{O|n2L>=ucJPKVG$0HC24x6?fkF9z0EEdQ0uzGLjGQ5PiMgqq$_@b_kr*K6 zV9;i8WbkDOW5{NxVwlJ0RR91 delta 80 zcmZoMXfc=|#>B`mu~2NHo+2aD#DLwC4MbQb^RqnNe4kB&akBykJIlm|C!5(h_&I>; dHVblmXP(S2Vky7?1dI#}Oi-F-bA-qmW&mHT5;6b) diff --git a/app/Filament/Pages/Auth/Register.php b/app/Filament/Pages/Auth/Register.php index 324d13b..c1f947e 100644 --- a/app/Filament/Pages/Auth/Register.php +++ b/app/Filament/Pages/Auth/Register.php @@ -40,7 +40,7 @@ class Register extends BaseRegister protected function mutateFormDataBeforeRegister(array $data): array { $data['phone_number'] = str_replace(' ', '', $data['phone_number']); - $data['email'] = $data['phone_number'] . '@telekechi.com'; + $data['email'] = $data['phone_number'].'@telekechi.com'; return $data; } diff --git a/app/Helpers/helpers.php b/app/Helpers/helpers.php index c58281a..8a87410 100644 --- a/app/Helpers/helpers.php +++ b/app/Helpers/helpers.php @@ -6,10 +6,8 @@ use App\Modules\ModuleContract; use App\Modules\ModuleRepository; use App\Modules\TurkmenNumberFormatter\Repositories\TurkmenNumberFormatter; use Illuminate\Contracts\Cache\Repository as CacheRepository; -use Illuminate\Http\Client\PendingRequest; use Illuminate\Support\Collection; use Illuminate\Support\Facades\DB; -use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Log; /** @@ -108,29 +106,3 @@ function moneyFormatInTurkmenLetter(int|float|string $money): string { return TurkmenNumberFormatter::format(floatval($money)); } - -/** - * Send a sms - */ -function sendSMS(string|int $phone, string|int $message): mixed -{ - $response = Http::retry( - times: 3, - sleepMilliseconds: 50, - throw: false, - when: function (Exception $exception, PendingRequest $request) { - Log::channel('sms_api_error') - ->error('Exception: ', [ - 'message' => $exception->getMessage(), - 'line' => $exception->getLine(), - ]); - - return true; - }) - ->post('http://216.250.14.144:3000/api/data', [ - 'phone' => '+993'.$phone, - 'code' => $message, - ]); - - return $response->body(); -} diff --git a/app/Modules/.DS_Store b/app/Modules/.DS_Store index 2a11c41a281d58ec9f19c9aec854c00464ad1d2f..5d3eef9d7e6ee3af0662ae45a637dfef9169e858 100644 GIT binary patch delta 49 zcmZoMXfc@J&&akhU^g=(+h!h?|BUR+48aV(48fD-SdPQkoByz?Gj3+*_{$FfN3sm~ delta 32 ocmZoMXfc@J&&aYdU^g=(%Vr*y|BRd8vq>;cYid(); + $table->string('username'); + $table->string('code'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('otp_verifications'); + } +}; diff --git a/app/Modules/OTPVerification/Models/OTPVerification.php b/app/Modules/OTPVerification/Models/OTPVerification.php new file mode 100644 index 0000000..853987e --- /dev/null +++ b/app/Modules/OTPVerification/Models/OTPVerification.php @@ -0,0 +1,25 @@ +enabled; + } + + /** + * Disable module + */ + public function disable(): void + { + $this->enabled = false; + } + + /** + * Enable module + */ + public function enable(): void + { + $this->enabled = true; + } + + /** + * Check if module has a filament resource + */ + public function hasFilamentResource(): bool + { + return true; + } +} diff --git a/app/Modules/OTPVerification/Repositories/OTPVerificationRepository.php b/app/Modules/OTPVerification/Repositories/OTPVerificationRepository.php new file mode 100644 index 0000000..6407814 --- /dev/null +++ b/app/Modules/OTPVerification/Repositories/OTPVerificationRepository.php @@ -0,0 +1,27 @@ + $phone_number])->first(); + $verification + ? $verification->update(['code' => $phone_code]) + : OTPVerification::create(['username' => $phone_number, 'code' => $phone_code]); + + SMSRepository::sendSMS($phone_number, 'Tassyklaýyş belgi: '.$phone_code); + + return $verification; + } +} diff --git a/app/Modules/SMS/Repositories/SMSRepository.php b/app/Modules/SMS/Repositories/SMSRepository.php new file mode 100644 index 0000000..8fa1ec1 --- /dev/null +++ b/app/Modules/SMS/Repositories/SMSRepository.php @@ -0,0 +1,36 @@ + $exception->getMessage(), + 'line' => $exception->getLine(), + ]); + + return true; + }) + ->post('http://216.250.14.144:3000/api/data', [ + 'phone' => '+993'.$phone, + 'code' => $message, + ]); + + return $response->body(); + } +} diff --git a/app/Modules/SMS/SMSModule.php b/app/Modules/SMS/SMSModule.php new file mode 100644 index 0000000..9264a64 --- /dev/null +++ b/app/Modules/SMS/SMSModule.php @@ -0,0 +1,48 @@ +enabled; + } + + /** + * Disable module + */ + public function disable(): void + { + $this->enabled = false; + } + + /** + * Enable module + */ + public function enable(): void + { + $this->enabled = true; + } + + /** + * Check if module has a filament resource + */ + public function hasFilamentResource(): bool + { + return true; + } +} diff --git a/database/migrations/2025_09_22_162906_add_extra_columns_to_users_table.php b/database/migrations/2025_09_22_162906_add_extra_columns_to_users_table.php index 677b80f..e2a3347 100644 --- a/database/migrations/2025_09_22_162906_add_extra_columns_to_users_table.php +++ b/database/migrations/2025_09_22_162906_add_extra_columns_to_users_table.php @@ -13,7 +13,7 @@ return new class extends Migration { Schema::table('users', function (Blueprint $table) { $table->softDeletes()->after('updated_at'); - $table->json('meta')->nullable()->after('remember_token'); + $table->json('meta')->nullable()->after('phone_number'); }); }