ldc-nature-eleveurs/app/Http/Requests/Bo/Users/UpdateUserRequest.php

48 lines
1 KiB
PHP
Raw Permalink Normal View History

2024-01-31 16:42:01 +01:00
<?php
namespace App\Http\Requests\Bo\Users;
use Illuminate\Support\Facades\Gate;
use Illuminate\Validation\Rule;
class UpdateUserRequest extends StoreUserRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize(): bool
{
return Gate::check('update', $this->route('user'));
}
/**
* Prepare the data for validation.
*
* @return void
*/
protected function prepareForValidation(): void
{
$this->merge([
2024-08-23 08:22:48 +02:00
'published' => $this->boolean('published')
2024-01-31 16:42:01 +01:00
]);
}
/**
* 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',
Rule::unique('users', 'email')->ignore(\optional($this->route('user'))->getRouteKey())
2024-08-23 08:22:48 +02:00
]
2024-01-31 16:42:01 +01:00
]);
}
}