Refactor imports and formatting in various Filament resources; add SMS sending helper function

This commit is contained in:
2025-09-22 16:31:13 +05:00
parent 60afe0c441
commit f14defeebd
27 changed files with 251 additions and 85 deletions

View File

@@ -0,0 +1,47 @@
<?php
namespace App\Filament\Pages\Auth;
use App\Modules\PhoneNumberVerification\Rules\PhoneNumberVerificationRule;
use Filament\Auth\Pages\Register as BaseRegister;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Schema;
class Register extends BaseRegister
{
public function form(Schema $schema): Schema
{
return $schema
->schema([
$this->getNameFormComponent(),
$this->getPhoneNumberFormComponent(),
$this->getPasswordFormComponent(),
$this->getPasswordConfirmationFormComponent(),
]);
}
protected function getPhoneNumberFormComponent(): TextInput
{
return TextInput::make('phone_number')
->prefix('+993')
->label('Telefon')
->mask('99 99 99 99')
->rules(['bail', 'required', new PhoneNumberVerificationRule, 'unique:users,phone_number'])
->autofocus();
}
protected function beforeValidate(): void
{
if (isset($this->data['phone_number'])) {
$this->data['phone_number'] = str_replace(' ', '', $this->data['phone_number']);
}
}
protected function mutateFormDataBeforeRegister(array $data): array
{
$data['phone_number'] = str_replace(' ', '', $data['phone_number']);
$data['email'] = $data['phone_number'] . '@telekechi.com';
return $data;
}
}