Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Attachment Library

Laravel Attachment Library Laravel Package

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.

View on GitHub
Deep Wiki
Context7

A Laravel library for attaching files to Eloquent models.

Frequently asked questions about Laravel Attachment Library
How do I install and set up Laravel Attachment Library in a Laravel project?
Run `composer require van-ons/laravel-attachment-library` to install the package, then execute `php artisan attachment-library:install` to publish migrations and assets. This sets up the required database tables and configurations automatically.
Which Laravel versions are supported by this package?
The package is designed for Laravel 9.x and 10.x. Check the package’s GitHub repository or `composer.json` for the exact supported versions, as minor updates may adjust compatibility.
Can I use this library with custom storage backends like S3 or Azure Blob?
Yes, the package supports Laravel’s filesystem configuration, so you can configure it to use S3, Azure, or other storage backends by updating the `config/filesystems.php` settings. The library leverages Laravel’s built-in filesystem adapters.
How do I attach files to an Eloquent model using this library?
Add the `HasAttachments` trait to your Eloquent model, then use the `attachments()` relationship to link files. For example, `$model->attachments()->attach($attachmentId)` connects an existing attachment to your model.
Does Laravel Attachment Library support image resizing or processing?
Yes, the library integrates with Laravel Glide for on-the-fly image manipulation, including resizing, cropping, and format conversion. This reduces server load by generating optimized images dynamically.
How does the package handle file metadata like EXIF data for images?
The library supports extracting metadata (e.g., EXIF for images) using configurable adapters like Gd or Imagick. Metadata is stored in the database alongside attachments, enabling rich file information retrieval.
Is there a way to organize attachments into directories or folders?
Yes, the package includes directory management with CRUD operations, allowing you to create hierarchical storage structures. Attachments can be nested under directories for better organization, especially useful for large-scale file repositories.
What happens if I need soft deletes for attachments instead of hard deletes?
By default, the library uses hard deletes. To implement soft deletes, you’ll need to manually configure the `Attachment` model to use Laravel’s soft delete functionality and update the relevant queries in your application.
Are there any performance considerations when using this library with high-volume attachments?
The library is optimized for performance, but recursive directory operations or large-scale attachments may introduce bottlenecks. Ensure your storage backend (e.g., S3) is properly configured, and consider caching strategies for Glide-generated images.
Does this package include a frontend UI for managing attachments, or do I need to build one?
The library does not include a standalone admin UI, but it integrates with Filament for admin panel support. You’ll need to build custom frontend interfaces or use third-party packages for full attachment management features.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky