ldc-legaulois/app/Http/Requests/Bo/Approaches/UpdateApproachRequest.php
2026-09-25 16:25:31 +02:00

34 lines
999 B
PHP

<?php
namespace App\Http\Requests\Bo\Approaches;
use App\Enums\Approaches\ApproachTypeEnum;
use Illuminate\Support\Facades\Gate;
class UpdateApproachRequest extends StoreApproachRequest
{
/**
* Prepare the data for validation.
*/
protected function prepareForValidation(): void
{
/** @var \App\Models\Approach $approachModel */
$approachModel = $this->route()->parameter('approach');
$this->merge([
'type' => intval($approachModel->type->value),
'button_url' => intval($approachModel->type->value) === ApproachTypeEnum::demarche->value()
? $this->input('button_url')
: null,
'published' => $this->boolean('published'),
]);
$this->mergePicture('picture');
}
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return Gate::check('update', $this->route('approach'));
}
}