ldc-supportweb/app/Http/Requests/ChangeTicketStatus.php
Jérémy Munsch b60913525b - bump to Bootstrap 5
- added ACL policies
- added CRUD generic
- added User crud
- added search bar
2021-06-18 15:39:19 +02:00

43 lines
1.1 KiB
PHP

<?php
namespace App\Http\Requests;
use App\Enums\Role;
use App\Enums\TicketStatus;
use Illuminate\Foundation\Http\FormRequest;
class ChangeTicketStatus extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return auth()->check() and
auth()->user()->role->equals(Role::admin());
}
/**
* 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())
]));
}
}
],
];
}
}