49 lines
1.6 KiB
PHP
49 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Pages\Auth;
|
|
|
|
use Filament\Auth\Pages\Login as BaseLogin;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Schemas\Schema;
|
|
use Illuminate\Validation\ValidationException;
|
|
use SensitiveParameter;
|
|
|
|
class Login extends BaseLogin
|
|
{
|
|
public function form(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
TextInput::make('username')
|
|
->label('نام کاربری')
|
|
->required()
|
|
->maxLength(255)
|
|
->autocomplete('username')
|
|
->autofocus()
|
|
->validationMessages([
|
|
'required' => 'وارد کردن نام کاربری الزامی است.',
|
|
'max' => 'نام کاربری نباید بیشتر از ۲۵۵ کاراکتر باشد.',
|
|
]),
|
|
$this->getPasswordFormComponent()
|
|
->validationMessages([
|
|
'required' => 'وارد کردن رمز عبور الزامی است.',
|
|
]),
|
|
$this->getRememberFormComponent(),
|
|
]);
|
|
}
|
|
|
|
protected function getCredentialsFromFormData(#[SensitiveParameter] array $data): array
|
|
{
|
|
return [
|
|
'username' => $data['username'],
|
|
'password' => $data['password'],
|
|
];
|
|
}
|
|
|
|
protected function throwFailureValidationException(): never
|
|
{
|
|
throw ValidationException::withMessages([
|
|
'data.username' => __('filament-panels::auth/pages/login.messages.failed'),
|
|
]);
|
|
}
|
|
} |