van-ons/laravel-attachment-library

A Laravel library for attaching files to Eloquent models.
9,223 3
Install
composer require van-ons/laravel-attachment-library
Latest Version:v1.7.4
PHP:^8.2
Laravel:10 – 13
License:MIT
Last Updated:Oct 20, 2026
Links: GitHub  ·  Packagist
Maintainer: vanons

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.


Related Packages

van-ons/filament-attachment-library

A Filament library for attaching files to Eloquent models.

8,121 11
aniftyco/laravel-attachments

Turn any field on your Eloquent models into attachments

1,126 13
outrightvision/api-model

Generate Laravel-like Api Models

122,988 4
jimbolino/laravel-model-builder

builds eloquent models based on the tables and relations found in your mysql dat...

11,819 30
egeatech/laravel-models

A package to better handle database operations via Eloquent Models.

3,985 1

Version History

Version Released PHP License
v1.7.4 ^8.2 MIT
v1.7.3 ^8.2 MIT
v1.7.2 ^8.2 MIT
v1.7.1 ^8.2 MIT
v1.7.0 ^8.2 MIT
Pre-releases (3)
Version Released PHP License
v1.0.0-rc3 ^8.2 MIT
v1.0.0-rc2 ^8.2 MIT
v1.0.0-rc1 ^8.2 MIT