diff --git a/app/Http/Controllers/DocumentController.php b/app/Http/Controllers/DocumentController.php index 776390a4016a..5dc073cdf274 100644 --- a/app/Http/Controllers/DocumentController.php +++ b/app/Http/Controllers/DocumentController.php @@ -150,6 +150,10 @@ class DocumentController extends BaseController $document->fill($request->all()); $document->save(); + if($document->documentable) { + $document->documentable->touch(); + } + return $this->itemResponse($document->fresh()); } diff --git a/app/Models/Document.php b/app/Models/Document.php index fa9ec12a9364..9019c3442968 100644 --- a/app/Models/Document.php +++ b/app/Models/Document.php @@ -86,7 +86,7 @@ class Document extends BaseModel ]; protected $touches = [ - 'documentable' + // 'documentable' ]; /** diff --git a/app/Repositories/DocumentRepository.php b/app/Repositories/DocumentRepository.php index a59cb2fe991c..e9c104c2a935 100644 --- a/app/Repositories/DocumentRepository.php +++ b/app/Repositories/DocumentRepository.php @@ -22,6 +22,9 @@ class DocumentRepository extends BaseRepository { $document->deleteFile(); $document->forceDelete(); + + if($document->documentable) + $document->documentable->touch(); } public function restore($document) diff --git a/app/Utils/Traits/SavesDocuments.php b/app/Utils/Traits/SavesDocuments.php index a6d3da04f5e1..c35aaa6bb833 100644 --- a/app/Utils/Traits/SavesDocuments.php +++ b/app/Utils/Traits/SavesDocuments.php @@ -49,7 +49,7 @@ trait SavesDocuments ))->handle(); } - // $entity->touch(); + $entity->touch(); } public function saveDocument($document, $entity, $is_public = true) @@ -78,7 +78,7 @@ trait SavesDocuments $is_public ))->handle(); - // $entity->touch(); + $entity->touch(); } } diff --git a/tests/Feature/DocumentsApiTest.php b/tests/Feature/DocumentsApiTest.php index 596f17e63e7c..e5fedcc35bbc 100644 --- a/tests/Feature/DocumentsApiTest.php +++ b/tests/Feature/DocumentsApiTest.php @@ -47,7 +47,7 @@ class DocumentsApiTest extends TestCase public function testDocumentFilters() { - Document::query()->withoutEvents()->withTrashed()->cursor()->each(function ($d) { + Document::query()->withTrashed()->cursor()->each(function ($d) { $d->forceDelete(); });