Download the PHP package givanov95/laravel-attachments without Composer
On this page you can find all versions of the php package givanov95/laravel-attachments. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download givanov95/laravel-attachments
More information about givanov95/laravel-attachments
Files in givanov95/laravel-attachments
Package laravel-attachments
Short Description Polymorphic file & image attachments for Laravel: HasImages / HasFiles traits, Image / File models with URL accessor, drag-drop reorder routes, UploadHelper for clean controller code.
License MIT
Informations about the package laravel-attachments
givanov95/laravel-attachments
Polymorphic file & image attachments for Laravel.
What's included
Image+FileEloquent models with appendedurlaccessor (usesStorage::disk()->url())HasImages+HasFilestraits:setImages($collection, 'section')/setFiles($collection, 'section')— staged + persisted insaved()hook- Multi-section support, accumulates across calls
- Optional
profileImageColumn()override that caches the first image's path on a column on the parent model (usessaveQuietly()to avoid recursion) deleting()hook cascades attachment delete
UploadHelper::uploadMultipleImages($request, 'images', 'subdir')— moves UploadedFile[] to disk, returns ready-to-stage modelsFileStr::generateUniqueFileName($uploadedFile)— collision-safe filenames- Routes (auto-registered):
images.destroy,images.order,files.destroy,files.download,files.order(id-based)
Install
Configuration
Defaults in config/attachments.php (publishable):
Override middleware to add 'verified', role guards, custom guards, etc. The image/file routes are registered under this middleware stack.
Usage
On a model
In a controller
Reading attachments
URL access
Frontend never constructs paths — the model exposes url:
Routes
Auto-registered (id-based, behind ['web', 'auth'] by default):
| Method | Path | Name |
|---|---|---|
| DELETE | /images/{image} |
images.destroy |
| PUT | /images/order |
images.order |
| DELETE | /files/{file} |
files.destroy |
| PUT | /files/order |
files.order |
| GET | /files/{file}/download |
files.download |
The order endpoints accept { orderArray: [id, id, ...] } and rewrite the order column to the array's position (1-indexed).
Development
Pre-commit hook
composer install / composer update symlinks the repo's pre-commit script into .git/hooks/pre-commit. It runs composer test + composer analyse before any commit that touches .php files — replacement for CI since the repo is private.
Bypass with git commit --no-verify when you genuinely need to (WIP commit, doc-only change you've already validated).
License
MIT
All versions of laravel-attachments with dependencies
illuminate/contracts Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0
illuminate/database Version ^11.0|^12.0|^13.0
illuminate/http Version ^11.0|^12.0|^13.0
illuminate/filesystem Version ^11.0|^12.0|^13.0
illuminate/routing Version ^11.0|^12.0|^13.0