user()->role->equals(Role::admin())) { $this->merge([ 'status' => TicketStatus::new()->value, ]); } return auth()->check(); } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { return [ 'project_id' => [ 'required', 'exists:projects,id', // @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed function ($attribute, $value, $fail) { if (!in_array($value, auth()->user()->projects()->pluck('id')->all())) { $fail(__('Veuillez choisir entre :values', [ 'value' => auth()->user()->projects()->pluck('name')->implode(',') ])); } } ], 'type' => [ 'required', // @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed function ($attribute, $value, $fail) { if (!in_array($value, TicketType::toValues())) { $fail(__('Veuillez choisir entre :values', [ 'value' => implode(',', TicketType::toLabels()) ])); } } ], '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()) ])); } } ], 'text' => 'required|string|min:40', 'file_ticket' => 'mimes:jpeg,jpg,png,pdf|max:2048', 'file_ticket2' => 'mimes:jpeg,jpg,png,pdf|max:2048', ]; } }