2024-04-04 13:00:12 +02:00
|
|
|
<?php
|
|
|
|
|
|
2024-04-12 12:15:18 +02:00
|
|
|
namespace App\Http\Requests\Bo\Approaches;
|
2024-04-04 13:00:12 +02:00
|
|
|
|
2024-06-27 12:10:22 +02:00
|
|
|
use App\Enums\Approaches\ApproachTypeEnum;
|
2024-04-04 13:00:12 +02:00
|
|
|
use Illuminate\Support\Facades\Gate;
|
|
|
|
|
|
2024-04-12 12:15:18 +02:00
|
|
|
class UpdateApproachRequest extends StoreApproachRequest
|
2024-04-04 13:00:12 +02:00
|
|
|
{
|
2024-05-28 15:51:23 +02:00
|
|
|
/**
|
|
|
|
|
* Prepare the data for validation.
|
|
|
|
|
*/
|
|
|
|
|
protected function prepareForValidation(): void
|
|
|
|
|
{
|
2024-06-06 11:12:12 +02:00
|
|
|
/** @var \App\Models\Approach $approachModel */
|
|
|
|
|
$approachModel = $this->route()->parameter('approach');
|
2024-05-28 15:51:23 +02:00
|
|
|
$this->merge([
|
2024-06-27 12:10:22 +02:00
|
|
|
'type' => intval($approachModel->type->value),
|
|
|
|
|
'button_url' => intval($approachModel->type->value) === ApproachTypeEnum::demarche->value()
|
|
|
|
|
? $this->input('button_url')
|
|
|
|
|
: null,
|
2026-09-25 16:25:31 +02:00
|
|
|
'published' => $this->boolean('published'),
|
2024-05-28 15:51:23 +02:00
|
|
|
]);
|
|
|
|
|
$this->mergePicture('picture');
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-04 13:00:12 +02:00
|
|
|
/**
|
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
|
*/
|
|
|
|
|
public function authorize(): bool
|
|
|
|
|
{
|
2024-04-12 12:15:18 +02:00
|
|
|
return Gate::check('update', $this->route('approach'));
|
2024-04-04 13:00:12 +02:00
|
|
|
}
|
|
|
|
|
}
|