Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Attachment Library Laravel Package

van-ons/laravel-attachment-library

A Laravel library for attaching files to Eloquent models. Install via Composer, run the install command to add migrations and assets, then use the HasAttachments trait on any model to link and retrieve attachments through a simple relationship.

View on GitHub
Deep Wiki
Context7

Laravel Attachment Library

Latest version on GitHub Total downloads GitHub issues License Plumb score

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.


Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core
nodisrupt/laravel-agent
sierratecnologia/media-manager