43 lines
905 B
PHP
43 lines
905 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Requests\Bo;
|
||
|
|
|
||
|
|
use Illuminate\Validation\Rule;
|
||
|
|
|
||
|
|
class UpdateUserRequest extends StoreUserRequest
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Prepare the data for validation.
|
||
|
|
*
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function prepareForValidation()
|
||
|
|
{
|
||
|
|
if (empty($this->post('password'))) {
|
||
|
|
$this->offsetUnset('password');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get the validation rules that apply to the request.
|
||
|
|
*
|
||
|
|
* @return array
|
||
|
|
*/
|
||
|
|
public function rules()
|
||
|
|
{
|
||
|
|
return \array_merge(
|
||
|
|
parent::rules(),
|
||
|
|
[
|
||
|
|
'password' => 'sometimes|string|min:8',
|
||
|
|
'email' => [
|
||
|
|
'required',
|
||
|
|
'string',
|
||
|
|
'email',
|
||
|
|
'max:255',
|
||
|
|
(new Rule())->unique('users')->ignore($this->user->id)
|
||
|
|
]
|
||
|
|
]
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|