nayem1108 / document-management
Document management tools
Requires
- php: ^7.4|^8.0|^8.1|^8.2
- illuminate/support: ^8.0|^9.0|^10.0|^11.0
Requires (Dev)
- orchestra/testbench: ^6.0|^7.0
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-10-29 22:15:36 UTC
README
This package provides a comprehensive solution for managing documents within a Laravel application. It includes essential features such as CRUD operations, event handling, and user notifications. Built with modern standards, this package supports PSR-1, PSR-2, and PSR-4, ensuring compatibility and ease of integration with other PHP libraries and frameworks. It is designed to be user-friendly and efficient, making it an ideal choice for developers looking to streamline document management tasks in their applications.
Installation
You can install the package via composer:
composer require nayem1108/document-management
Usage
To use the Document Management package, you will need to follow these steps:
-
Import the Package: In your controller, import the
Document
model provided by the package:use Nayem1108\DocumentManagement\Models\Document;
-
Creating a Document: You can create a new document using the following code:
$document = Document::create([ 'title' => 'Document Title', 'description' => 'Description of the document', 'file_path' => 'path/to/document.pdf', ]);
-
Retrieving Documents: To retrieve all documents, use:
$documents = Document::all();
-
Updating a Document: Update an existing document by finding it first:
$document = Document::find($id); $document->update([ 'title' => 'Updated Title', 'description' => 'Updated description', ]);
-
Deleting a Document: To delete a document, you can use:
$document = Document::find($id); $document->delete();
-
Using Events: You can listen for document events (like creation or deletion) in your application:
use Nayem1108\DocumentManagement\Events\DocumentCreated; Event::listen(DocumentCreated::class, function ($event) { // Handle the event (e.g., send a notification) });
-
Blade View Integration: In your Blade view, display the documents using DataTables, as previously described.
This package simplifies the management of documents in Laravel, making it easy to perform common operations with just a few lines of code.
Testing
To ensure the functionality of the Document Management package, you can run the provided tests using PHPUnit. Follow these steps:
-
Run Tests: Execute the following command to run all tests:
composer test
-
Test Coverage: To generate a code coverage report, use the following command:
composer test-coverage
-
Writing Tests: You can find the test files located in the
tests
directory of the package. To add your own tests, create a new test class extendingTests\TestCase
and place it in the appropriate directory. Here's an example of a basic test:namespace Nayem1108\DocumentManagement\Tests; use Nayem1108\DocumentManagement\Models\Document; use Tests\TestCase; class DocumentTest extends TestCase { public function test_document_creation() { $document = Document::create([ 'title' => 'Test Document', 'description' => 'A document for testing', 'file_path' => 'path/to/test-document.pdf', ]); $this->assertDatabaseHas('documents', [ 'title' => 'Test Document', ]); } }
This testing framework ensures that your package is working as expected and helps you catch any issues early in the development process. Feel free to explore the existing tests for examples and best practices.
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email nayem110899@gmail.com instead of using the issue tracker.
Credits
License
This package is licensed under the MIT License (MIT). You can view the full text of the license in the License File.
By using this package, you agree to comply with the terms outlined in the license.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate. The boilerplate provides a solid foundation for developing Laravel packages, ensuring best practices and a structured approach to package development.
Key features of the boilerplate include:
- Standardized Structure: Follows PSR standards for autoloading, coding style, and documentation.
- Testing Setup: Comes with a testing suite using PHPUnit to ensure your package functions correctly.
- Easy Integration: Designed for seamless integration with Laravel applications, making it easy to install and use.
- Configuration Management: Provides a straightforward way to manage package configuration settings.
Feel free to explore the boilerplate for additional features and tools that can enhance your package development experience.