ui updates for ticket layout now with multipel attachments
This commit is contained in:
@@ -15,7 +15,7 @@ use Modules\Helpdesk\Services\AttachmentService;
|
||||
final class TicketAttachmentStoreController extends Controller
|
||||
{
|
||||
/**
|
||||
* Store one or more ticket-level supporting files for an existing ticket.
|
||||
* Store one or more supporting files directly against an existing ticket.
|
||||
*/
|
||||
public function __invoke(Request $request, Ticket $ticket, AttachmentService $attachments): RedirectResponse
|
||||
{
|
||||
@@ -27,23 +27,18 @@ final class TicketAttachmentStoreController extends Controller
|
||||
$request->validate([
|
||||
'attachments' => ['required', 'array', 'min:1'],
|
||||
'attachments.*' => ['required', 'file', 'max:'.$maxUploadKilobytes, 'mimes:'.implode(',', $allowedMimes)],
|
||||
], [
|
||||
'attachments.required' => 'Choose at least one supporting file.',
|
||||
'attachments.*.file' => 'Each supporting file must be a valid uploaded file.',
|
||||
]);
|
||||
|
||||
$user = Auth::user();
|
||||
abort_if($user === null, 403);
|
||||
|
||||
$uploadedFiles = $request->file('attachments', []);
|
||||
$uploadedFiles = is_array($uploadedFiles) ? array_values($uploadedFiles) : [$uploadedFiles];
|
||||
$uploadedFiles = is_array($uploadedFiles) ? array_values(array_filter($uploadedFiles)) : [$uploadedFiles];
|
||||
|
||||
$attachments->storeMany($ticket, $uploadedFiles, (int) $user->id);
|
||||
|
||||
$ticket->forceFill(['last_activity_at' => now()])->save();
|
||||
|
||||
return redirect()
|
||||
->route('helpdesk.tickets.show', $ticket)
|
||||
->with('ticket-attachments-added', count($uploadedFiles).' supporting file'.(count($uploadedFiles) === 1 ? '' : 's').' attached.');
|
||||
->with('ticket-attachments-added', count($uploadedFiles).' supporting file'.(count($uploadedFiles) === 1 ? '' : 's').' uploaded.');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user