- How do I install Filament Attachment Library in a Laravel project with Filament v4 or v5?
- Run `composer require van-ons/filament-attachment-library:^2.0` to install the package, then execute `php artisan filament-attachment-library:install` to set up migrations and assets. Ensure you have Filament v4 or v5 installed, as this package is version-locked to those.
- Does this package support S3 or other cloud storage backends for attachments?
- Yes, the package leverages Laravel’s built-in storage system, so you can configure it to use S3, local storage, or any other supported backend via Laravel’s filesystem configuration. No additional setup is required beyond your existing storage configuration.
- Can I customize the UI of the attachment manager to match my Filament theme?
- The package uses Tailwind CSS for styling, so you can override or extend its styles by creating a custom Filament theme. Add the provided CSS snippets to your `theme.css` file, and the attachment manager will adapt to your theme’s design.
- What Laravel and Filament versions does this package support?
- The package requires Laravel 8.0+ and is compatible with Filament v4 and v5. Version 2.x explicitly targets Filament 4.0+ and 5.0+, while version 1.x supports older Filament versions. Always check the compatibility table in the README for exact version requirements.
- How do I add attachments to an Eloquent model?
- Use the `HasAttachments` trait on your Eloquent model and define a `attachments()` relationship method. The package will automatically handle the pivot table or morphable attachments. Example: `use HasAttachments; public function attachments() { return $this->morphMany(Attachment::class, 'attachable'); }`
- Will this package work with Filament v6 when it’s released?
- Currently, the package is tightly coupled to Filament v4/v5 and does not officially support v6. If Filament v6 introduces breaking changes, you may need to wait for an updated version of this package or consider alternatives. Monitor the GitHub repository for announcements.
- Are there performance concerns with large-scale attachments (e.g., thousands per model)?
- The package does not include built-in optimizations for large-scale attachments, such as background processing or chunked uploads. For high-volume use cases, consider implementing Laravel queues for processing or optimizing your storage backend (e.g., S3 with lifecycle policies).
- How do I migrate existing attachments from another system to this library?
- Manually create records in the `attachments` table (or your custom pivot table) for each file, ensuring the `attachable_id` and `attachable_type` fields match your Eloquent models. Use Laravel’s model events or a data migration script to automate the process if needed.
- Does this package provide API endpoints to fetch attachments programmatically?
- No, the package is UI-focused and integrates directly with Filament’s admin panel. For API access, you’ll need to create custom routes or use Laravel’s built-in file responses. The package provides methods like `getUrl()` to generate secure attachment URLs for frontend or API use.
- I’m using a custom storage disk for attachments. How do I configure it?
- Configure your custom disk in Laravel’s `filesystems.php` under the `disks` array, then set the `default` or `attachments` disk in the package’s config file (published via `php artisan vendor:publish`). The package will automatically use the configured disk for all uploads and storage operations.