van-ons / laravel-attachment-library
A Laravel library for attaching files to Eloquent models.
Installs: 0
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/van-ons/laravel-attachment-library
Requires
- php: ^8.2
- league/glide-symfony: ^2.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.64
- larastan/larastan: ^2.9
- orchestra/testbench: ^8.21
- phpunit/phpunit: ^10.1
This package is auto-updated.
Last update: 2025-10-22 07:52:03 UTC
README
Laravel Attachment Library
A Laravel library for attaching files to Eloquent models.
Quick start
Installation
The Laravel Attachment Library can be installed using Composer by running the following command:
$ composer require van-ons/laravel-attachment-library
After downloading the dependency, run the following command to install all the migrations and assets:
$ php artisan attachment-library:install
Usage
To enable file attachments in your Eloquent models, add the HasAttachments
trait to your model class:
namespace App\Models; use Illuminate\Database\Eloquent\Model; use VanOns\LaravelAttachmentLibrary\Concerns\HasAttachments; class ModelName extends Model { use HasAttachments; // ... }
After that you should be able to link attachments to your model as follows:
// Retrieve attachment. $attachment = \VanOns\LaravelAttachmentLibrary\Models\Attachment::find($attachmentId); // Retrieve your model. $myModel = ModelName::find($modelId); // Link attachment to your model. $myModel->attachments()->attach($attachment);
Documentation
Please see the documentation for detailed information about installation and usage.
Contributing
Please see contributing for more information about how you can contribute.
Changelog
Please see changelog for more information about what has changed recently.
Upgrading
Please see upgrading for more information about how to upgrade.
Security
Please see security for more information about how we deal with security.
Credits
We would like to thank the following contributors for their contributions to this project:
License
The scripts and documentation in this project are released under the MIT License.