feat: Implement Document Module with Dropzone file upload functionality
- Added DocumentController for handling document uploads and management. - Created Document model with necessary attributes and relationships. - Implemented DocumentService for business logic related to documents. - Set up routes for document management in both web and API contexts. - Developed views for document upload using Dropzone for file handling. - Included necessary assets and styles for the Document module. - Created migration for documents table with appropriate fields. - Added configuration and service provider for the Document module.
This commit is contained in:
0
Modules/Document/app/Services/.gitkeep
Normal file
0
Modules/Document/app/Services/.gitkeep
Normal file
49
Modules/Document/app/Services/DocumentService.php
Normal file
49
Modules/Document/app/Services/DocumentService.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Document\Services;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\Document\Models\Document;
|
||||
|
||||
class DocumentService
|
||||
{
|
||||
|
||||
public function getAllCategories()
|
||||
{
|
||||
$query = Document::query();
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
public function storeDocument(array $documentData): Document
|
||||
{
|
||||
return DB::transaction(function () use ($documentData) {
|
||||
$document = Document::create($documentData);
|
||||
|
||||
return $document;
|
||||
});
|
||||
}
|
||||
|
||||
public function getDocumentById(int $id)
|
||||
{
|
||||
return Document::findOrFail($id);
|
||||
}
|
||||
|
||||
public function updateDocument(int $id, array $documentData)
|
||||
{
|
||||
$document = $this->getDocumentById($id);
|
||||
|
||||
return DB::transaction(function () use ($document, $documentData) {
|
||||
$document->update($documentData);
|
||||
return $document;
|
||||
});
|
||||
}
|
||||
|
||||
public function deleteDocument(int $id)
|
||||
{
|
||||
return DB::transaction(function () use ($id) {
|
||||
$document = $this->getDocumentById($id);
|
||||
$document->delete();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user