PHPackages                             victorscatolon/filament-attachment-library - 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. [Image &amp; Media](/categories/media)
4. /
5. victorscatolon/filament-attachment-library

ActiveLibrary[Image &amp; Media](/categories/media)

victorscatolon/filament-attachment-library
==========================================

Easily manage file attachments across multiple models using a clean, polymorphic approach in your Filament app.

v1.0.4(7mo ago)71081MITPHPPHP ^8.1

Since Apr 11Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/victorscatolon/filament-attachment-library)[ Packagist](https://packagist.org/packages/victorscatolon/filament-attachment-library)[ RSS](/packages/victorscatolon-filament-attachment-library/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (5)Used By (0)

Filament Attachment Library
===========================

[](#filament-attachment-library)

Filament Attachment Library is a Laravel package that enables a polymorphic morphMany relationship to handle file attachments across multiple Eloquent models. Seamlessly integrated with Filament, it offers a clean, reusable, and consistent approach to managing file uploads through Filament resource forms and tables—making attachment handling simple and scalable across your application.

🚀 Installation
--------------

[](#-installation)

Install the package via Composer:

```
composer require victorscatolon/filament-attachment-library
```

Then publish the package's migration files:

```
php artisan vendor:publish --tag="filament-attachment-library-migrations"
```

⚙️ Configuration
----------------

[](#️-configuration)

1. Create your model If you haven’t already, create a new Eloquent model:

```
php artisan make:model MyModel
```

2. Enable attachments on your model Add the `InteractsWithAttachments` trait to your model to define the polymorphic relationship:

```
use VictorScatolon\FilamentAttachmentLibrary\Core\InteractsWithAttachments;

class MyModel extends Model
{
    use InteractsWithAttachments;
}
```

3. Add the file upload field to your Filament form In your Filament resource's `form` method, include the `AttachmentLibraryFileUpload` component to allow users to upload files:

```
use VictorScatolon\FilamentAttachmentLibrary\Forms\Components\AttachmentLibraryFileUpload;

public static function form(Form $form): Form
{
    return $form
        ->schema([
            AttachmentLibraryFileUpload::make(),
        ]);
}
```

4. Enable attachment handling in the CreateRecord component To ensure attachments are saved properly when creating a new model, use the `HandleAttachments` trait in your `CreateRecord` class:

**CreateRecord component**

```
use VictorScatolon\FilamentAttachmentLibrary\Core\HandleAttachments;

class CreateMyModel extends CreateRecord
{
    use HandleAttachments;
}
```

5. Enable attachment handling in the EditRecord component Likewise, use the HandleAttachments trait in your EditRecord class to manage attachments during updates:

**EditRecord component**

```
use VictorScatolon\FilamentAttachmentLibrary\Core\HandleAttachments;

class EditMyModel extends EditRecord
{
    use HandleAttachments;
}
```

🗂️ Relation Managers
--------------------

[](#️-relation-managers)

To use the Attachment Library within a Relation Manager form, follow these steps:

1. Use the HandleAttachments trait Add the `HandleAttachments` trait to your `RelationManager` class:

```
use VictorScatolon\FilamentAttachmentLibrary\Core\HandleAttachments;

class MyRelationManager extends RelationManager
{
    use HandleAttachments;
}
```

2. Set `dehydrated(true)` on the file upload field Make sure the attachment field is dehydrated so that the file data is available during form processing:

```
public function form(Form $form): Form
{
    return $form
        ->schema([
            AttachmentFileUpload::make()->dehydrated(true),
        ]);
}
```

3. Add a custom create action to the table You’ll need to define a custom `CreateAction` with an `after()` callback to manually handle the attachments after the record is created:

```
public function table(Table $table): Table
{
    return $table->headerActions([
            Tables\Actions\CreateAction::make()
                ->after(function ($record, $data) {
                    $attachments = $data['attachments'];
                    $this->handleAttachments($record, $attachments);
                }),
        ]);
}
```

✅ Note: Make sure the field name in the $data array matches the field key used in the AttachmentLibraryFileUpload::make() definition.

📦 Changelog
-----------

[](#-changelog)

For a detailed list of recent changes, updates, and improvements, please refer to the [Changelog](https://github.com/victorscatolon/filament-attachment-library/blob/main/CHANGELOG.md).

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! To get started, please read the [Contribution Guide](https://github.com/victorscatolon/filament-attachment-library/blob/main/CONTRIBUTING.md).

👨‍💻 Credits
-----------

[](#‍-credits)

Developed and maintained by [@victorscatolon](https://github.com/victorscatolon).
Thanks to all the amazing contributors who help improve this package.

📄 License
---------

[](#-license)

This project is open-source software licensed under the [MIT License](https://github.com/victorscatolon/filament-attachment-library/blob/main/LICENSE.md).

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance62

Regular maintenance activity

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~53 days

Total

4

Last Release

237d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1acecc2092c1199f65b44609457fc4a70be3f80ed30c9d04bba81275c9a0915b?d=identicon)[victorscatolon](/maintainers/victorscatolon)

---

Top Contributors

[![victorscatolon](https://avatars.githubusercontent.com/u/11843723?v=4)](https://github.com/victorscatolon "victorscatolon (7 commits)")

---

Tags

laravellibrarymediaattachmentfile-uploadfilamentrelationshippolymorphicmorphMany

### Embed Badge

![Health badge](/badges/victorscatolon-filament-attachment-library/health.svg)

```
[![Health](https://phpackages.com/badges/victorscatolon-filament-attachment-library/health.svg)](https://phpackages.com/packages/victorscatolon-filament-attachment-library)
```

###  Alternatives

[tomatophp/filament-media-manager

Manage your media files using spatie media library with easy to use GUI for FilamentPHP

14543.9k3](/packages/tomatophp-filament-media-manager)[silvanite/nova-field-cloudinary

A Laravel Nova Image Field with Flysystem Adapter for storing and retrieving media from Cloudinary

2772.0k3](/packages/silvanite-nova-field-cloudinary)[mariojgt/witchcraft

A Laravel Package Witchcraft, a quick start for new laravel Packages

312.6k](/packages/mariojgt-witchcraft)[webplusm/gallery-json-media

a filament media storing in a Json field

196.0k](/packages/webplusm-gallery-json-media)[zeeshantariq/filament-attachmate

Implement a polymorphic morphMany relationship for managing attachments within Filament

229.6k](/packages/zeeshantariq-filament-attachmate)

PHPackages © 2026

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