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

v1.0.0 2025-10-16 13:05 UTC

README

Social card of Laravel Attachment Library

Laravel Attachment Library

Latest version on GitHub Total downloads GitHub issues License

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.

Logo of Van Ons