38 lines
883 B
PHP
38 lines
883 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Requests\App\Settings;
|
|
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class ProfileDeleteRequest extends FormRequest
|
|
{
|
|
/**
|
|
* @return array<string, ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
if ($this->user()->password) {
|
|
return [
|
|
'password' => ['required', 'string', 'current_password'],
|
|
];
|
|
}
|
|
|
|
return [
|
|
'email_confirmation' => ['required', 'string', Rule::in([$this->user()->email])],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'email_confirmation.in' => __('settings.delete_account.email_mismatch'),
|
|
];
|
|
}
|
|
}
|