validate([ 'commentBody' => ['required', 'string', 'min:2'], 'attachments' => ['nullable', 'array'], 'attachments.*' => [ 'file', 'max:'.config('helpdesk.max_upload_kb', 10240), 'mimes:'.implode(',', config('helpdesk.allowed_mimes', ['jpg', 'jpeg', 'png', 'pdf', 'txt', 'log', 'zip'])), ], ]); $user = Auth::user(); if ($user === null) { throw ValidationException::withMessages([ 'commentBody' => 'You must be signed in to comment on this ticket.', ]); } $internal = $request->user()?->can('update', $ticket) === true && $request->boolean('internal'); $tickets->comment( ticket: $ticket, user: $user, body: (string) $validated['commentBody'], internal: $internal, files: $request->file('attachments', []), ); return redirect() ->route('helpdesk.tickets.show', $ticket) ->with('ticket-comment-added', 'Reply posted.'); } }