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
Filament Attachment Library

Filament Attachment Library Laravel Package

van-ons/filament-attachment-library

Filament Attachment Library adds a simple attachments manager to your Filament panel: upload files, browse and select existing attachments, and store them in a central library. Includes installer command, migrations/assets, and Tailwind-ready templates.

View on GitHub
Deep Wiki
Context7

A Filament library for attaching files to Eloquent models.

Frequently asked questions about Filament Attachment Library
How do I install Filament Attachment Library in a Laravel project with Filament v3.2+?
Run `composer require van-ons/filament-attachment-library:^2.0` followed by `php artisan filament-attachment-library:install`. This installs migrations and assets. Ensure you have Filament 3.2+ and Laravel 11+ with PHP 8.2+ for compatibility. The installer will guide you through setting up a custom Tailwind theme.
Can I use this package with Filament v4 or Laravel 10?
No, this package is strictly designed for Filament v3.2+ and Laravel 11+. Filament v4 or Laravel 10 may require updates or alternative solutions. Check the [compatibility docs](https://github.com/VanOns/filament-attachment-library/blob/main/docs/compatibility.md) for future support plans.
What storage options does Filament Attachment Library support?
The package supports any Laravel filesystem disk (local, S3, database, etc.). By default, it uses the `public` disk, but you can override this in `.env` with `ATTACHMENTS_DISK=disk_name`. For production, dedicate a separate disk to avoid conflicts and optimize performance.
How do I integrate attachments into an Eloquent model?
Use the `HasAttachments` trait for polymorphic attachments or `HasAttachment` for single-file models. Add the trait to your model, then define the attachment field in your Filament resource using `AttachmentField`. Example: `use HasAttachments;` and `AttachmentField::make('attachments')->label('Files').`
Does this package support image optimization (e.g., resizing, compression)?
Yes, if you have [Laravel Glide](https://spatie.be/docs/laravel-glide) configured, the package integrates with it for image optimization. Ensure `glide.php` is properly set up, or manually configure the `Attachment` model to use Glide for processing. Non-image files are stored as-is.
How can I customize the file upload UI or validation rules?
Extend the `AttachmentField` in your Filament resource to customize validation (e.g., `->required()->maxSize(10)`). For UI changes, override the Blade templates in your custom Filament theme by extending `tailwind.config.js` and including the package’s assets. Alpine.js handles interactivity, so you can modify its behavior via JavaScript.
What happens if I need to roll back migrations after installation?
The `filament-attachment-library:install` command runs migrations automatically. To roll back, use `php artisan migrate:rollback`. However, manual cleanup may be required for orphaned files or database entries, especially if you customized the default `attachments` table structure.
Can I use this package for multi-tenancy (e.g., separate storage per tenant)?
Yes, but you’ll need to customize the storage logic. Override the `Attachment` model’s `getDisk()` method to dynamically return a tenant-specific disk (e.g., `tenant_{$tenantId}_disk`). Alternatively, use Laravel’s filesystem adapters to scope paths by tenant ID.
How do I handle large files (e.g., videos) or concurrent uploads?
For large files, consider chunked uploads or queueing with Laravel Queues. Configure a dedicated disk (e.g., S3) with proper permissions. For concurrent uploads, ensure your storage backend (e.g., S3) supports high throughput, or implement rate limiting in your Filament resource.
Are there alternatives to Filament Attachment Library for Laravel?
Yes. For Filament, consider [spatie/laravel-filament-media-library](https://github.com/spatie/laravel-filament-media-library) (built on Spatie’s media library). For non-Filament solutions, [spatie/laravel-medialibrary](https://spatie.be/docs/laravel-medialibrary) or [intervention/image](https://image.intervention.io/v2) (for image-specific needs) are popular. Choose based on your need for Filament integration or broader Laravel compatibility.
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.
nasirkhan/laravel-sharekit
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony