ldc-crm/app/Http/Requests/Bo/Users/UpdateUserRequest.php

40 lines
939 B
PHP
Raw Normal View History

2023-10-06 15:00:42 +02:00
<?php
namespace App\Http\Requests\Bo\Users;
class UpdateUserRequest extends StoreUserRequest
{
/**
* Prepare the data for validation.
*
* @return void
*/
protected function prepareForValidation(): void
2023-10-06 15:00:42 +02:00
{
$this->merge([
'published' => $this->input('published') ? true : false,
'brand_id' => $this->input('brand_id') ?: [],
2023-10-06 15:00:42 +02:00
]);
}
/**
* 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');
2023-10-06 15:00:42 +02:00
return array_merge(parent::rules(), [
'email' => [
2023-10-06 15:00:42 +02:00
'required',
'string',
2023-10-06 15:00:42 +02:00
'email:rfc,strict,dns,spoof,filter',
'unique:users,email,' . $userModel->getKey(),
2023-10-06 15:00:42 +02:00
],
]);
}
}