43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Domains\Auth\Requests;
|
|
|
|
use App\Domains\Authorization\Enums\RoleCode;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
use Illuminate\Validation\Rules\Password;
|
|
|
|
class RegisterUserRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
protected function prepareForValidation(): void
|
|
{
|
|
if (is_string($this->input('email'))) {
|
|
$this->merge(['email' => mb_strtolower(trim($this->input('email')))]);
|
|
}
|
|
}
|
|
|
|
/** @return array<string, mixed> */
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'tenant_codigo' => ['nullable', 'string', Rule::exists('tenants', 'codigo')],
|
|
'nombre_apellido' => ['required', 'string', 'max:255'],
|
|
'email' => [
|
|
'required',
|
|
'string',
|
|
'email',
|
|
'max:255',
|
|
Rule::unique('users', 'active_email')->where('rol_codigo', RoleCode::User->value)->whereNull('deleted_at'),
|
|
],
|
|
'password' => ['required', 'string', 'confirmed', Password::min(8)->mixedCase()->symbols()],
|
|
'dni' => ['nullable', 'string', 'max:255'],
|
|
'telefono' => ['nullable', 'string', 'max:255'],
|
|
];
|
|
}
|
|
}
|