- 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.