- How do I install the Laravel Attachment Library?
- Run composer require van-ons/laravel-attachment-library, then run php artisan attachment-library:install. The install command publishes the package migrations and assets so you can set up the attachments tables and related files.
- How do I attach an uploaded file to an Eloquent model?
- Add the HasAttachments trait to your Eloquent model, then load an existing Attachment model and call attachments()->attach($attachment) on your model. The package links the attachment record to the model through the attachments relationship.
- Does Laravel Attachment Library work with any Eloquent model?
- Yes, any Eloquent model can use the HasAttachments trait to gain an attachments relationship. The README shows linking an existing Attachment to a model with attachments()->attach, so you can associate uploads with models such as users, posts, or custom records.
- Which Laravel versions are supported by van-ons/laravel-attachment-library?
- The provided README does not list Laravel version constraints. Check the package's composer.json on Packagist or GitHub before installing to confirm compatibility with your Laravel version.
- Can I store attachments on S3 instead of the public disk?
- The package defaults to Laravel's public disk, but its storage layer is configurable. For S3 or other non-default disks, expect to adjust the package storage configuration and verify that upload, delete, and Glide image handling work with that disk.
- How does image resizing work in Laravel Attachment Library?
- It integrates with Laravel Glide to provide on-the-fly image manipulation such as resizing and cropping. That keeps dynamic image delivery out of your application code and relies on Glide caching to reduce repeated processing.
- Does the package provide an admin UI for managing attachments?
- No, there is no standalone admin UI for attachment management. The package integrates with Filament according to the evaluation, but teams still need to build their own interfaces for browsing, uploading, or organizing attachments.
- Are attachments soft-deleted by default?
- No. Attachments are hard-deleted by default, so soft deletes or archiving require custom logic in your application. Plan for this if you need recoverable file records.
- How can I customize file naming or metadata extraction?
- The package uses modular, configurable components such as file namers, metadata retrievers, and storage adapters. You can customize these via configuration instead of forking the core library, which helps tailor attachment behavior to your app.
- Is Laravel Attachment Library safe to use in production?
- The package is well-structured and Laravel-native, but it has low adoption with few GitHub stars and no listed dependents. Treat it as medium risk and validate edge cases, storage behavior, and performance under your expected load before relying on it in production.