48 lines
1.4 KiB
PHP
48 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Bo\Users;
|
|
|
|
use Illuminate\Validation\Rules\Password;
|
|
|
|
class UpdateUserRequest extends StoreUserRequest
|
|
{
|
|
/**
|
|
* Prepare the data for validation.
|
|
*
|
|
* @return void
|
|
*/
|
|
protected function prepareForValidation()
|
|
{
|
|
$this->merge([
|
|
'published' => $this->published ? true : false,
|
|
'password' => $this->password ? $this->password : $this->route('user')->password,
|
|
'password_confirmation' => $this->password_confirmation ?
|
|
$this->password_confirmation :
|
|
$this->route('user')->password
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return array_merge(parent::rules(), [
|
|
'email' => [
|
|
'required',
|
|
'email:rfc,strict,dns,spoof,filter',
|
|
'unique:users,email,' . $this->route('user')->id . ',id',
|
|
],
|
|
'password' => [
|
|
'required', 'required_with:password_confirmation', 'confirmed', 'max:255', Password::min(8)
|
|
->letters()
|
|
->mixedCase()
|
|
->numbers()
|
|
->symbols()
|
|
->uncompromised()
|
|
],
|
|
]);
|
|
}
|
|
}
|