|
|
@@ -4,12 +4,24 @@ namespace App\Http\Requests;
|
|
|
|
|
|
use App\Enums\UserTypeEnum;
|
|
|
use App\Models\User;
|
|
|
+use App\Support\Cpf;
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
use Illuminate\Validation\Rule;
|
|
|
use Illuminate\Validation\Rules\Password;
|
|
|
|
|
|
class FirstAccessRegisterRequest extends FormRequest
|
|
|
{
|
|
|
+ protected function prepareForValidation(): void
|
|
|
+ {
|
|
|
+ if ($this->has('cpf')) {
|
|
|
+ $this->merge(['cpf' => Cpf::digits($this->input('cpf'))]);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($this->has('registration')) {
|
|
|
+ $this->merge(['registration' => trim((string) $this->input('registration'))]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public function rules(): array
|
|
|
{
|
|
|
$user = $this->existingUser();
|
|
|
@@ -20,7 +32,7 @@ class FirstAccessRegisterRequest extends FormRequest
|
|
|
'registration' => ['required', 'string', 'max:255', Rule::unique('users', 'registration')->ignore($userId)],
|
|
|
'name' => 'required|string|min:3|max:120',
|
|
|
'last_name' => 'required|string|min:3|max:120',
|
|
|
- 'cpf' => ['required', 'string', 'max:14', Rule::unique('users', 'cpf')->ignore($userId)],
|
|
|
+ 'cpf' => ['required', 'string', 'digits:11', Rule::unique('users', 'cpf')->ignore($userId)],
|
|
|
'email' => ['required', 'email', 'max:255', Rule::unique('users', 'email')->ignore($userId)],
|
|
|
'phone' => 'required|string|max:20',
|
|
|
'position_id' => 'required|integer|exists:positions,id',
|