39 lines
939 B
PHP
39 lines
939 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Bo\Users;
|
|
|
|
class UpdateUserRequest extends StoreUserRequest
|
|
{
|
|
/**
|
|
* Prepare the data for validation.
|
|
*
|
|
* @return void
|
|
*/
|
|
protected function prepareForValidation(): void
|
|
{
|
|
$this->merge([
|
|
'published' => $this->input('published') ? true : false,
|
|
'brand_id' => $this->input('brand_id') ?: [],
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
/** @var \App\Models\User $userModel */
|
|
$userModel = request()->route()->parameter('user');
|
|
|
|
return array_merge(parent::rules(), [
|
|
'email' => [
|
|
'required',
|
|
'string',
|
|
'email:rfc,strict,dns,spoof,filter',
|
|
'unique:users,email,' . $userModel->getKey(),
|
|
],
|
|
]);
|
|
}
|
|
}
|