Weave Code
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

Attach files to Laravel Eloquent models with a simple HasAttachments trait and Attachment model. Includes installer command for migrations/assets and an attachments relationship to link existing uploads to any model.

View on GitHub
Deep Wiki
Context7

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.


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.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle