- What Laravel versions does this package support?
- This package is designed for Laravel 5.3-era workflows but explicitly states compatibility with Laravel 5.3+. However, the TPM assessment suggests Laravel 8+ is likely required due to Vue 3 syntax in the `MediaBrowser.vue` component. Test thoroughly if using Laravel 9+ due to potential route caching changes.
- How do I upload files to a custom disk like S3?
- Use the `storage()` method on the `Upload` helper to specify a disk before handling the request. For example, `$media = Upload::storage('s3')->handle($request, 'file');`. The package automatically saves the disk name to the database, ensuring your app knows where to retrieve the file later.
- Can I use this package with a non-Vue frontend like React or Angular?
- The package includes a Vue 3 component (`MediaBrowser.vue`) for media browsing, which won’t work natively with React or Angular. You’d need to create a wrapper component or build a custom UI. The backend API (Eloquent model, upload handler) remains usable, but the frontend integration requires extra effort.
- Does this package support soft deletes for media files?
- Yes, the package includes soft-delete functionality via Eloquent’s `deleted_at` column. Media can be restored using `Media::where('id', 1)->restore()`, and the `AjaxController` handles soft-deletes with a 409 conflict response if the media is linked to other models. Ensure your database migration includes the `deleted_at` column.
- How do I handle 409 conflict errors when deleting linked media?
- The package returns a 409 conflict response when attempting to delete media linked to other models. Your frontend (Vue) should handle this by displaying a confirmation dialog or warning. Use Axios interceptors or Vue’s error handling to catch and display these errors gracefully, especially in the `MediaBrowser.vue` component.
- Can I customize the image styles or caching behavior?
- Yes, the package supports generating and caching image variants (styles). You can configure these in the package’s config file (published via `php artisan vendor:publish`). Customize the `styles` array to define resolutions, formats, or disk locations for cached images. The system uses Laravel’s filesystem drivers for storage.
- Is this package production-ready, or should I avoid it for critical apps?
- The package is labeled as under development, and the README explicitly states it’s not recommended for production environments. Use it cautiously, especially if you rely on its stability. Consider forking or contributing to stabilize it for your needs, or evaluate alternatives like Spatie Media Library for production-critical projects.
- How do I add a 1-to-many media relation to my Eloquent models?
- Use the provided trait (`HasMedia`) on your Eloquent models. This automatically creates a `media()` relationship method, allowing you to attach media like `$post->media()->attach($mediaId)`. The trait handles the inverse relationship, so media models will also reference your parent model.
- What dependencies does this package require beyond Laravel?
- The package requires Vue 3 (or Vue 2 with polyfills) and Bootstrap 3 for the frontend components. Backend dependencies include Laravel’s filesystem drivers (e.g., S3, local) and the `dropzone` library for file uploads. Install Dropzone via `npm install dropzone --save-dev` and include its JS in your `app.js`.
- Are there alternatives to this package for Laravel media management?
- Yes, consider Spatie Media Library for a more mature, production-ready solution with broader Laravel version support (5.5+). Other options include Intervention Image for image processing, Laravel Filemanager for admin panels, or custom solutions using Laravel’s filesystem and Eloquent. Evaluate based on your needs for soft deletes, Vue integration, and disk flexibility.