- What is padosoft/laravel-uploadable and how does it work?
- It is a Laravel package that provides an Eloquent trait for attaching and managing file uploads directly on your models. The trait handles storage, validation, and cleanup so you can add upload support with minimal configuration. It relies on Laravel's filesystem and disk abstractions rather than implementing its own storage layer.
- How do I install padosoft/laravel-uploadable with Composer?
- Install it with Composer using composer require padosoft/laravel-uploadable. Then add the provided trait to any Eloquent model that should support uploads. Check the repository README and composer.json for the exact service provider or configuration publishing steps, since these details are not captured in the release notes.
- Which Laravel and PHP versions does laravel-uploadable support?
- Version compatibility cannot be confirmed from the release note alone. You should check the package's composer.json constraints and full changelog before upgrading, especially across the 4.x to 5.0.0 boundary. Run your integration tests against the exact Laravel and PHP versions you deploy.
- How do I add file uploads to an Eloquent model using a trait?
- Add the package's uploadable trait to the model and configure the upload options for that model. The trait then manages storing the file, applying validation, and cleaning up replaced or removed files. Keep model configuration explicit so storage behavior stays predictable across environments.
- How do I configure storage disks and upload options?
- Upload behavior is configured through an UploadOptions style object, and in version 5.0.0 the public $storage property was removed in favor of a getStorage() accessor. Replace any direct reads or writes of the storage property with the supported accessor and constructor or setter pattern. Confirm whether getStorage() returns a disk name or a Disk instance, because that affects testability and serialization.
- What changed in laravel-uploadable 5.0.0 and how do I upgrade?
- Version 5.0.0 is a major breaking change: the public UploadOptions::$storage property is gone and storage is now resolved through getStorage(). Any code that reads, writes, or serializes $storage will fail or behave differently. Pin to 4.x while you audit usages, migrate call sites, and then validate queue and serialization paths before rolling out.
- Can I queue uploads and serialize UploadOptions safely?
- The 5.0.0 change appears aimed at fixing serialization problems caused by storing a non-serializable Laravel Disk object on an options DTO. Encapsulating storage resolution behind getStorage() is a better boundary for queued or cached payloads. Still, verify whether the accessor returns a serializable disk name or a live Disk instance before relying on it in jobs and failed-job payloads.
- How do I validate uploads and clean up old files with laravel-uploadable?
- The trait handles validation and cleanup as part of its upload management, so you configure the rules and storage behavior on the model rather than wiring it manually. Cleanup typically applies when files are replaced or the model is deleted. Test these paths explicitly, because cleanup behavior can differ by disk driver and deployment setup.
- How do I test file uploads with laravel-uploadable?
- Use Laravel's fake storage disks and the package's options API to assert that files land where expected and that old files are removed. In 5.0.0, update any test factories, reflection helpers, or serializer fixtures that reference the removed $storage property. Add coverage for queue and cache serialization if UploadOptions is persisted across deployments.
- Are there alternatives to laravel-uploadable for Laravel file uploads?
- Alternatives include handling uploads directly with Laravel's filesystem and validation APIs, or using media library style packages for more advanced attachment management. Laravel Uploadable is a good fit when you want a lightweight trait that adds uploads to any model with minimal configuration. Evaluate alternatives against your needs for disk drivers, cleanup policies, and queue-safe option objects.