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

48 lines
1 KiB
PHP
Raw Normal View History

2023-12-19 15:09:12 +00:00
<?php
namespace App\Http\Requests\Bo\Users;
2024-01-26 16:08:12 +01:00
use Illuminate\Support\Facades\Gate;
use Illuminate\Validation\Rule;
2023-12-19 15:09:12 +00:00
class UpdateUserRequest extends StoreUserRequest
{
2024-01-26 16:08:12 +01:00
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize(): bool
{
return Gate::check('update', $this->route('user'));
}
2023-12-19 15:09:12 +00:00
/**
* Prepare the data for validation.
*
* @return void
*/
2024-01-26 16:08:12 +01:00
protected function prepareForValidation(): void
2023-12-19 15:09:12 +00:00
{
$this->merge([
2025-03-06 16:06:54 +01:00
'published' => $this->boolean('published'),
2023-12-19 15:09:12 +00:00
]);
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(): array
{
return array_merge(parent::rules(), [
2024-01-26 16:08:12 +01:00
'email' => [
2023-12-19 15:09:12 +00:00
'required',
'email:rfc,strict,dns,spoof,filter',
2024-01-26 16:08:12 +01:00
Rule::unique('users', 'email')->ignore(\optional($this->route('user'))->getRouteKey())
2023-12-19 15:09:12 +00:00
],
]);
}
}