van-ons/laravel-attachment-library
Attach files to Laravel Eloquent models with a simple HasAttachments trait and Attachment model. Includes installer command for migrations/assets and an attachments relationship to link existing uploads to any model.
The AttachmentManager facade is the main part of this package. This class is responsible for uploading, deleting, modifying
and moving files while making sure that the database representation stays in sync.
The AttachmentManager offers many ways to manage attachments.
$attachmentModel = \VanOns\LaravelAttachmentLibrary\Facades\AttachmentManager::upload($attachment);
$attachmentModel = \VanOns\LaravelAttachmentLibrary\Facades\AttachmentManager::move($attachment, 'new/path');
$attachmentModel = \VanOns\LaravelAttachmentLibrary\Facades\AttachmentManager::rename($attachment, 'newName');
$attachmentModel = \VanOns\LaravelAttachmentLibrary\Facades\AttachmentManager::delete($attachment);
The AttachmentManager also offers ways to manage directories.
$attachmentModel = \VanOns\LaravelAttachmentLibrary\Facades\AttachmentManager::createDirectory('path/directory-name');
$attachmentModel = \VanOns\LaravelAttachmentLibrary\Facades\AttachmentManager::renameDirectory('path/directory-name', 'new-name');
[!WARNING] This will also remove any files and subdirectories in the directory. Make sure the directory is empty if you don't want to remove any files.
$attachmentModel = \VanOns\LaravelAttachmentLibrary\Facades\AttachmentManager::deleteDirectory('path/directory-name');
How can I help you explore Laravel packages today?