ldc-cocotte/app/Http/Requests/Fo/Customer/UpdatePasswordRequest.php

52 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2026-06-14 21:32:07 +02:00
<?php
declare(strict_types=1);
namespace App\Http\Requests\Fo\Customer;
use App\Cqs\Actions\Crm\UpdateCustomerPasswordInput;
2026-06-14 21:32:07 +02:00
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rules\Password;
use Infrastructure\Adapters\Services\AppCustomerAuthService;
class UpdatePasswordRequest extends FormRequest
{
public function __construct(
private readonly AppCustomerAuthService $authService
) {
}
public function authorize(): bool
{
return $this->authService->check();
}
public function toUpdateCustomerPasswordInput(): UpdateCustomerPasswordInput
{
return new UpdateCustomerPasswordInput(
$this->string('password_old')->value(),
$this->string('password')->value()
);
}
2026-06-14 21:32:07 +02:00
/** @return array<string,mixed> */
public function rules(): array
{
return [
'password_old' => ['required'],
'password' => [
'required',
'required_with:password_confirmation',
'confirmed',
'max:255',
Password::min(8)
->mixedCase()
->letters()
->numbers()
->symbols()
->uncompromised(),
],
];
}
}