2023-11-13 11:56:06 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Requests\Bo\Users;
|
|
|
|
|
|
2024-02-12 15:51:31 +01:00
|
|
|
use Illuminate\Support\Facades\Gate;
|
|
|
|
|
use Illuminate\Validation\Rule;
|
2023-11-13 11:56:06 +01:00
|
|
|
|
|
|
|
|
class UpdateUserRequest extends StoreUserRequest
|
|
|
|
|
{
|
2024-02-12 15:51:31 +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-11-13 11:56:06 +01:00
|
|
|
/**
|
|
|
|
|
* Prepare the data for validation.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
2024-02-12 15:51:31 +01:00
|
|
|
protected function prepareForValidation(): void
|
2023-11-13 11:56:06 +01:00
|
|
|
{
|
|
|
|
|
$this->merge([
|
2025-03-06 14:51:21 +00:00
|
|
|
'published' => $this->boolean('published'),
|
2023-11-13 11:56:06 +01:00
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
|
*
|
2026-04-24 15:04:18 +02:00
|
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
2023-11-13 11:56:06 +01:00
|
|
|
*/
|
|
|
|
|
public function rules(): array
|
|
|
|
|
{
|
|
|
|
|
return array_merge(parent::rules(), [
|
2024-02-12 15:51:31 +01:00
|
|
|
'email' => [
|
2023-11-13 11:56:06 +01:00
|
|
|
'required',
|
|
|
|
|
'email:rfc,strict,dns,spoof,filter',
|
2024-02-12 15:51:31 +01:00
|
|
|
Rule::unique('users', 'email')->ignore(\optional($this->route('user'))->getRouteKey())
|
2025-03-06 14:51:21 +00:00
|
|
|
]
|
2023-11-13 11:56:06 +01:00
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|