PHPackages                             asseco-voice/laravel-attachments - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. asseco-voice/laravel-attachments

ActiveLibrary[Database &amp; ORM](/categories/database)

asseco-voice/laravel-attachments
================================

Laravel support for attachments

v2.17.1(6mo ago)36.3k↓100%1[3 PRs](https://github.com/asseco-voice/laravel-attachments/pulls)MITPHPPHP ^8.1CI passing

Since Mar 18Pushed 6mo ago5 watchersCompare

[ Source](https://github.com/asseco-voice/laravel-attachments)[ Packagist](https://packagist.org/packages/asseco-voice/laravel-attachments)[ RSS](/packages/asseco-voice-laravel-attachments/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (8)Versions (39)Used By (0)

[![](https://github.com/asseco-voice/art/raw/main/evil_logo.png)](https://see.asseco.com)

Attachments
===========

[](#attachments)

Purpose of this repository is to enable attachment upload and connecting it to any Laravel model as an M:M relation.

Installation
------------

[](#installation)

Require the package with `composer require asseco-voice/laravel-attachments`. Service provider will be registered automatically.

Setup
-----

[](#setup)

In order to use the package, migrate the tables with `artisan migrate`and add `Attachable` trait to model you'd like to have attachment support on.

```
use Asseco\Attachments\App\Traits\Attachable;

class Product extends Model
{
    use Attachable;

    // ...
}
```

Standard CRUD endpoints are exposed for attachment administration where you can, among others, store an attachment. Due to the fact that attachments are a morph relation, you have to provide your own controllers for attaching/detaching those attachments to attachable models.

Example:

```
Route::post('models/{model}/attachments', [ModelAttachmentController::class, 'store']);

public function store(Request $request, Model $model): JsonResponse
{
    $ids = Arr::get($request->validated(), 'attachment_ids', []);

    $model->attachments()->sync($ids);

    return response()->json('success');
}
```

Cached attachments
==================

[](#cached-attachments)

Option to keep attachments in filesystem, or cache. Based on value ATTACHMENTS\_CACHE\_TYPE, there are two scenarios:

- FILE
    - attachments are stored in filesystem (ATTACHMENTS\_CACHE\_LOCATION)
    - mapping is saved in cache key ATTACHMENTS\_CACHE\_MAP\_KEY
        - \[attachment1-&gt;id =&gt; path1, attachment2-&gt;id =&gt; path2, ...\]
- CACHE
    - attachment content is stored in cache, 1 attachment = 1 cache key
    - cache key is named as: ATTACHMENTS\_CACHE\_KEY\_PREFIX + attachment\_id

ENV variables which controls the behaviour:

- ATTACHMENTS\_CACHE\_ENABLED=true (default: false)
- ATTACHMENTS\_CACHE\_MAP\_KEY="ASEE\_ATTACHMENTS\_MAP" (default: ASEE\_ATTACHMENTS\_MAP)
- ATTACHMENTS\_CACHE\_TYPE="FILE" (default: FILE)
- ATTACHMENTS\_CACHE\_LOCATION="/tmp/" (default: sys\_get\_temp\_dir())
- ATTACHMENTS\_CACHE\_KEY\_PREFIX="ASEE\_ATTACHMENT\_" (default: ASEE\_ATTACHMENT\_)
- ATTACHMENTS\_CACHE\_TIME=3600 (default: 3600 seconds)

Extending the package
=====================

[](#extending-the-package)

Publishing the configuration will enable you to change package models as well as controlling how migrations behave. If extending the model, make sure you're extending the original model in your implementation.

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance66

Regular maintenance activity

Popularity26

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~49 days

Recently: every ~6 days

Total

35

Last Release

197d ago

Major Versions

v0.6.0 → v1.0.02022-05-05

v1.1.0 → v2.0.02023-08-08

PHP version history (3 changes)v0.1.0PHP ^7.4 || ^8.0

v1.0.0PHP ^8.0

v2.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/d61de45741b74e7d4a9ee5778160cf54ae5e94a615ae1a6f72b6d1e5fae68d12?d=identicon)[Norgul](/maintainers/Norgul)

---

Top Contributors

[![Norgul](https://avatars.githubusercontent.com/u/11718157?v=4)](https://github.com/Norgul "Norgul (33 commits)")[![assefvisic](https://avatars.githubusercontent.com/u/60132037?v=4)](https://github.com/assefvisic "assefvisic (18 commits)")[![ngaspari](https://avatars.githubusercontent.com/u/33628128?v=4)](https://github.com/ngaspari "ngaspari (11 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![DaveXo9](https://avatars.githubusercontent.com/u/85836822?v=4)](https://github.com/DaveXo9 "DaveXo9 (4 commits)")[![AkronimBlack](https://avatars.githubusercontent.com/u/39061674?v=4)](https://github.com/AkronimBlack "AkronimBlack (2 commits)")[![AirMike](https://avatars.githubusercontent.com/u/561217?v=4)](https://github.com/AirMike "AirMike (1 commits)")[![DevFajdetic](https://avatars.githubusercontent.com/u/67901712?v=4)](https://github.com/DevFajdetic "DevFajdetic (1 commits)")[![josip-milotic](https://avatars.githubusercontent.com/u/42002911?v=4)](https://github.com/josip-milotic "josip-milotic (1 commits)")[![BuleWu](https://avatars.githubusercontent.com/u/124057240?v=4)](https://github.com/BuleWu "BuleWu (1 commits)")

---

Tags

laravellaravel8microservicespackagephpphplaraveldatabaseattachmentsmicroservices

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/asseco-voice-laravel-attachments/health.svg)

```
[![Health](https://phpackages.com/badges/asseco-voice-laravel-attachments/health.svg)](https://phpackages.com/packages/asseco-voice-laravel-attachments)
```

###  Alternatives

[wayofdev/laravel-cycle-orm-adapter

🔥 A Laravel adapter for CycleORM, providing seamless integration of the Cycle DataMapper ORM for advanced database handling and object mapping in PHP applications.

3516.7k3](/packages/wayofdev-laravel-cycle-orm-adapter)[codewithkyrian/chromadb-laravel

ChromaDB Laravel is a Laravel client for the Chroma Open Source Embedding Database

144.1k](/packages/codewithkyrian-chromadb-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
