diff --git a/app/.DS_Store b/app/.DS_Store index a19d0e0..1e06f78 100644 Binary files a/app/.DS_Store and b/app/.DS_Store differ 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 2a11c41..5d3eef9 100644 Binary files a/app/Modules/.DS_Store and b/app/Modules/.DS_Store differ diff --git a/app/Modules/OTPVerification/Controllers/OTPVerificationController.php b/app/Modules/OTPVerification/Controllers/OTPVerificationController.php new file mode 100644 index 0000000..c44e92b --- /dev/null +++ b/app/Modules/OTPVerification/Controllers/OTPVerificationController.php @@ -0,0 +1,49 @@ +id(); + $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'); }); }