ldc-legaulois/app/Http/Requests/Bo/Approaches/UpdateApproachRequest.php

35 lines
999 B
PHP
Raw Permalink Normal View History

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
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
{
/**
* 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');
$this->merge([
'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'),
]);
$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
}
}