2021-04-18 20:31:07 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
|
|
|
|
|
|
use App\Enums\TicketStatus;
|
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
|
|
|
|
|
class ChangeTicketStatus extends FormRequest
|
|
|
|
|
{
|
2021-05-18 19:33:36 +02:00
|
|
|
/**
|
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
|
*
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
public function authorize()
|
|
|
|
|
{
|
2021-07-23 11:04:09 +02:00
|
|
|
/** @var \App\Models\User */
|
|
|
|
|
$user = auth()->user();
|
|
|
|
|
return auth()->check() and $user->isAdmin();
|
2021-05-18 19:33:36 +02:00
|
|
|
}
|
|
|
|
|
|
2021-04-18 20:31:07 +02:00
|
|
|
/**
|
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function rules()
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'status' => [
|
|
|
|
|
'required',
|
|
|
|
|
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
|
|
|
|
function ($attribute, $value, $fail) {
|
|
|
|
|
if (!in_array($value, TicketStatus::toValues())) {
|
|
|
|
|
$fail(__('Veuillez choisir entre :values', [
|
|
|
|
|
'value' => implode(',', TicketStatus::toLabels())
|
|
|
|
|
]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|