json($documents); } public function downloadDocument(int $documentID): ResponseInterface { $document = \Document::find($documentID); $filePath = ROOTPATH . 'documents/' . $document->storagename; if (!file_exists($filePath)) { return $this->json(['error' => 'File not found']); } $data = file_get_contents($filePath); return $this->response->download($document->originalname, $data); } public function removeDocument(int $documentID): ResponseInterface { $document = \Document::find($documentID); $filePath = ROOTPATH . 'documents/' . $document->storagename; if (file_exists($filePath)) { unlink($filePath); } \Document::whereId($documentID)->delete(); return $this->json(['success' => true]); } }