diff --git a/app/Http/Controllers/DocumentController.php b/app/Http/Controllers/DocumentController.php index 317b5c436c..a1c2082f59 100644 --- a/app/Http/Controllers/DocumentController.php +++ b/app/Http/Controllers/DocumentController.php @@ -78,7 +78,7 @@ class DocumentController extends BaseController return $this->itemResponse($document); } - public function download(DownloadDocumentRequest $request, Document $document) + public function download(ShowDocumentRequest $request, Document $document) { return response()->streamDownload(function () use($document) { echo file_get_contents($document->generateUrl()); @@ -93,7 +93,7 @@ class DocumentController extends BaseController */ public function edit(EditDocumentRegquest $request, Document $document) { - // + return $this->itemResponse($document); } /** @@ -105,7 +105,7 @@ class DocumentController extends BaseController */ public function update(UpdateDocumentRequest $request, Document $document) { - // + return $this->itemResponse($document); } /** diff --git a/app/Models/Document.php b/app/Models/Document.php index 63c736dfdf..ed62e2bc75 100644 --- a/app/Models/Document.php +++ b/app/Models/Document.php @@ -115,9 +115,7 @@ class Document extends BaseModel public function generateRoute($absolute = false) { - return route('api.documents.show', ['document' => $this->hashed_id]); - - //return route('document.show', ['document' => $this->hashed_id]); + return route('api.documents.show', ['document' => $this->hashed_id]) . '/download'; } public function deleteFile() diff --git a/app/Repositories/DocumentRepository.php b/app/Repositories/DocumentRepository.php index 33da05b4a9..3620985bb9 100644 --- a/app/Repositories/DocumentRepository.php +++ b/app/Repositories/DocumentRepository.php @@ -35,8 +35,16 @@ class DocumentRepository extends BaseRepository $document->forceDelete(); } - public function restore() + public function restore($document) { + if (! $document->trashed()) { + return; + } + $document->restore(); + + if (class_exists($className)) { + event(new $className($document)); + } } } diff --git a/routes/api.php b/routes/api.php index 48dff4be83..e7713fdc41 100644 --- a/routes/api.php +++ b/routes/api.php @@ -70,7 +70,7 @@ Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'a Route::post('vendors/bulk', 'VendorController@bulk')->name('vendors.bulk'); Route::resource('documents', 'DocumentController');// name = (documents. index / create / show / update / destroy / edit - + Route::get('documents/{document}/download', 'DocumentController@download')->name('documents.download'); Route::post('documents/bulk', 'DocumentController@bulk')->name('documents.bulk'); Route::resource('client_statement', 'ClientStatementController@statement');// name = (client_statement. index / create / show / update / destroy / edit