ldc-supportweb/app/Http/Requests/SortTickets.php

45 lines
1.2 KiB
PHP
Raw Normal View History

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 [
'search' => 'nullable|string',
2021-04-18 20:31:07 +02:00
'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-07-23 11:34:16 +02:00
'pr' => 'sometimes|int|exists:sites,id'
2021-04-18 20:31:07 +02:00
];
}
}