43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Bo;
|
|
|
|
use App\Enums\Tickets\TicketStatusEnum;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class ChangeTicketStatus extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function authorize()
|
|
{
|
|
/** @var \App\Models\User */
|
|
$user = auth()->user();
|
|
return auth()->check() and $user->isAdmin();
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
'status' => [
|
|
'required',
|
|
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
|
|
function ($attribute, $value, $fail) {
|
|
if (!in_array($value, TicketStatusEnum::toValues())) {
|
|
$fail(__('Veuillez choisir entre :values', [
|
|
'value' => implode(',', TicketStatusEnum::toLabels())
|
|
]));
|
|
}
|
|
}
|
|
],
|
|
];
|
|
}
|
|
}
|