storage = Storage::disk('local'); } public function getAfterIngest($id) { $path = $this->getPath($id); // Ingest success. if ($this->storage->exists("$path/document.md")) { return [ 'status' => 'success', 'content' => $this->getDocumentContent($id, $path), ]; } // Ingest fail. if ($this->storage->exists("$path/document")) { return [ 'status' => 'fail', ]; } return [ 'status' => 'processing', 'message' => 'Document has not been processed yet.', ]; } public function destroy($id) { $path = $this->getPath($id); return $this->storage->deleteDirectory($path); } protected function getPath($id) { return "contracts/$id"; } protected function getDocumentContent($id, $path) { $content = $this->storage->get("$path/document.md"); $imageFullPath = url('/') . '/contracts-images/' . $id . '/'; $imageFullPath = str_replace( ' ', '%20', $imageFullPath); // @TODO Use preg_replace to find correctly formatted images and any wild cards for the image caption. // return str_replace('![](./', '![](' . $imageFullPath, $content); return str_replace('](./', '](' . $imageFullPath, $content); } }