2021-04-18 20:31:07 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
|
|
|
|
|
|
use App\Enums\TicketStatus;
|
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
|
|
|
|
|
class SortTickets extends FormRequest
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
|
*
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
public function authorize()
|
|
|
|
|
{
|
|
|
|
|
return auth()->check();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function rules()
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'sort_way' => 'sometimes|in:asc,desc',
|
|
|
|
|
'status' => [
|
|
|
|
|
'sometimes',
|
|
|
|
|
// @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())
|
|
|
|
|
]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
],
|
2021-04-21 15:08:47 +02:00
|
|
|
'pr' => 'sometimes|int|exists:projects,id'
|
2021-04-18 20:31:07 +02:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|