- What Laravel and Filament versions does this package support?
- The package requires Laravel 9+ and Filament 4.0 or 5.0 (depending on the version). Check the [compatibility docs](https://github.com/VanOns/filament-attachment-library/blob/main/docs/compatibility.md) for exact version mappings. Always verify compatibility before installing to avoid breaking changes.
- How do I install and set up Filament Attachment Library?
- Run `composer require van-ons/filament-attachment-library:^2.0` and then `php artisan filament-attachment-library:install` to handle migrations and assets. You’ll also need to create a custom Filament theme and extend `tailwind.config.js` to include the package’s Blade templates for styling.
- Can I use a custom storage disk for attachments?
- Yes, the package defaults to the `public` disk but allows overriding via `.env` with `ATTACHMENTS_DISK=disk_name`. It’s recommended to use a dedicated disk to avoid conflicts, especially for production environments with high attachment volumes.
- Does this package support image processing (e.g., resizing, format conversion)?
- Yes, it integrates with Glide for dynamic image processing. If your project doesn’t already use Glide, you’ll need to install it (`composer require spatie/laravel-medialibrary` or similar) and configure it in `glide.php`. This adds minimal overhead but enables features like on-the-fly resizing.
- How do I associate attachments with Eloquent models?
- The package uses Laravel’s morph-to-many relationship, so you can attach files to any model by defining a relationship like `public function attachments() { return $this->morphToMany(Attachment::class, 'attachable'); }`. The installer creates the necessary pivot table and migrations automatically.
- Will this work with my existing Filament resources?
- Yes, the package is designed to integrate seamlessly with Filament Resources and Forms. You can add attachment fields to your existing forms or create dedicated attachment resources. The UI is built using Filament’s component system, so it blends naturally with your admin panel.
- Are there performance concerns with large numbers of attachments?
- The package is optimized for scalability, but performance depends on your storage backend (e.g., S3 vs. local disk). For 10K+ files, consider using a dedicated disk like S3 with proper caching. The morph-to-many relationship is efficient, but query scopes (e.g., `whereHas`) should be used to limit loaded attachments.
- How do I customize the UI or override default styles?
- The package uses TailwindCSS, so you can override styles by extending the theme in your `theme.css` file. For deeper customization, you can publish the package’s views (`php artisan vendor:publish --tag=filament-attachment-library-views`) and modify the Blade templates directly.
- What security measures are in place for file uploads?
- The package validates file types and sizes via Filament’s built-in upload handlers. For additional security, configure allowed MIME types in `config/filament-attachment-library.php` and avoid dynamic `basePath` values in storage disks to prevent path traversal risks. Always use a dedicated disk for attachments.
- Are there alternatives to this package for Filament file management?
- Alternatives include `spatie/laravel-medialibrary` (more generic, not Filament-specific) or `filament/spatie-media-library-integration` (a Filament wrapper for Media Library). This package stands out for its tight Filament integration, installer command, and Glide support, making it ideal for Filament-centric projects.