PHPackages                             van-ons/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. [Database &amp; ORM](/categories/database)
4. /
5. van-ons/filament-attachment-library

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

van-ons/filament-attachment-library
===================================

A Filament library for attaching files to Eloquent models.

v2.2.7(1mo ago)72.8k↓15.6%[2 PRs](https://github.com/VanOns/filament-attachment-library/pulls)MITPHPPHP ^8.2CI passing

Since Jun 7Pushed 2mo agoCompare

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

READMEChangelog (10)Dependencies (10)Versions (58)Used By (0)

[![Social card of Filament attachment library](art/social-card.png)](art/social-card.png)

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

[](#filament-attachment-library)

[![Latest version on GitHub](https://camo.githubusercontent.com/579960313f25af7d5126043e01744caf12c06caa5864cffaf1289e79527e648c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f56616e4f6e732f66696c616d656e742d6174746163686d656e742d6c6962726172792e7376673f7374796c653d666c61742d737175617265)](https://github.com/VanOns/filament-attachment-library/releases)[![Total downloads](https://camo.githubusercontent.com/ee1cba32ea5f96b8d5e009c7dff87b25b683fa71361164effb074727c25529dd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f76616e2d6f6e732f66696c616d656e742d6174746163686d656e742d6c6962726172792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/van-ons/filament-attachment-library)[![GitHub issues](https://camo.githubusercontent.com/b2c409eff1d1b1866c5ec5150548221c2af040f0ca9f80946279a37daa043d3c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f56616e4f6e732f66696c616d656e742d6174746163686d656e742d6c6962726172793f7374796c653d666c61742d737175617265)](https://github.com/VanOns/filament-attachment-library/issues)[![License](https://camo.githubusercontent.com/c84e5bb984241cdfa2c72f0cfde61849d48f92935841c333eabbc1d922d283ce/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f56616e4f6e732f66696c616d656e742d6174746163686d656e742d6c6962726172793f7374796c653d666c61742d737175617265)](https://github.com/VanOns/filament-attachment-library/blob/main/LICENSE.md)

Filament package for easy attachment uploading and browsing.

Quick start
-----------

[](#quick-start)

### Compatibility

[](#compatibility)

For certain Filament versions, changes have to be made that render the package backwards incompatible with the previous version. Please see the table below to determine which version you need.

VersionFilamentv2 (current)&gt;=4.0 | &gt;=5.0[v1](https://github.com/VanOns/filament-attachment-library/tree/release/v1)&lt;4.0**Please note:** the `main` branch will always be the latest major version.

### Installation

[](#installation)

The Filament Attachment Library can be installed using Composer by running the following command:

```
composer require van-ons/filament-attachment-library:^2.0
```

An installation command is available that ensures that the migrations and assets are installed:

```
php artisan filament-attachment-library:install
```

The templates in this package use TailwindCSS. To ensure the styling is rendered correctly, a custom Filament theme must be set up, and the `tailwind.config.js` file should be extended.

Create the custom Filament theme and follow the instructions in the terminal to set it up:

```
php artisan make:filament-theme [PANEL_NAME]
```

Add the following to the generated `theme.css` file:

```
// resources/css/filament/[PANEL_NAME]/theme.css
@source '../../../../vendor/van-ons/filament-attachment-library/resources/**/*.blade.php'
```

Note

Make sure to follow the instructions in the terminal to register your custom Filament theme in the admin panel.

If your project is using Vite, you may have to register the custom theme as follows: `->viteTheme('resources/css/filament/[PANEL_NAME]/theme.css', 'build')`

By default, this package uses the `public` disk defined in `filesystems.php`. This can be overridden by adding the following to the project's `.env` file:

```
ATTACHMENTS_DISK=disk_name_here
```

Note

It is advised to use a disk without any other files. This prevents file conflicts.

The `glide.php` and `attachment-library.php` files contain more configuration options.

#### Prepare model

[](#prepare-model)

Register the plugin in the desired Filament panel:

```
namespace App\Providers\Filament;

use VanOns\FilamentAttachmentLibrary\FilamentAttachmentLibrary;

class ExamplePanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            ->plugin(
                FilamentAttachmentLibrary::make()->navigationGroup('Files')
            );
    }

}
```

### Usage

[](#usage)

The attachment field can be used in two ways: either to store the attachments in a specific column of your model, or to store the attachments in the `attachments` relationship by using the `HasAttachments` trait and the `relationship()` method.

(Optional) Add the `HasAttachments` trait to your desired model:

```
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use VanOns\LaravelAttachmentLibrary\Concerns\HasAttachments;

class ModelName extends Model
{
    use HasAttachments;

    // ...
}
```

This will add the `attachments()` relationship which links one or more attachments to your model.

Then, in your form schema, add the `AttachmentField`:

```
namespace App\Filament\Resources;

use Filament\Forms;
use Filament\Forms\Form;
use VanOns\FilamentAttachmentLibrary\Forms\Components\AttachmentField;

public static function form(Form $form): Form
{
    return $form
        ->schema([
            // ...
            // If you want to store the attachments in a column
            AttachmentField::make('featured_image'),
            // Or if you want to store attachments in the attachments relationship with a specific collection name
            AttachmentField::make('gallery')->relationship(),
            // Or if you want the collection name to be different from the field name
            AttachmentField::make('gallery')->relationship()->collection('product_gallery'),
        ]);
}
```

(Optional) When using the `relationship()` method, you can filter the attachments by collection name. To make this easier you can add a separate relationship method to your model:

```
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
use VanOns\LaravelAttachmentLibrary\Concerns\HasAttachments;

class ModelName extends Model
{
    use HasAttachments;

    public function gallery(): MorphToMany
    {
        return $this->attachmentCollection('gallery');
    }
}
```

Finally, at the front end, the `laravel-attachment-library-image` Blade component can be used to display attachments as image. Glide is used to scale the image up or down. The `src` argument may be an Attachment instance, or the id as string/integer.

```

```

For more information refer to the [Laravel Attachment Library documentation](https://github.com/VanOns/laravel-attachment-library).

Documentation
-------------

[](#documentation)

Please see the [documentation](docs/README.md#contents) for detailed information about installation and usage.

Contributing
------------

[](#contributing)

Please see [contributing](CONTRIBUTING.md) for more information about how you can contribute.

Changelog
---------

[](#changelog)

Please see [changelog](CHANGELOG.md) for more information about what has changed recently.

Upgrading
---------

[](#upgrading)

Please see [upgrading](UPGRADING.md) for more information about how to upgrade.

Security
--------

[](#security)

Please see [security](SECURITY.md) for more information about how we deal with security.

Credits
-------

[](#credits)

We would like to thank the following contributors for their contributions to this project:

- [All Contributors](../../contributors)

License
-------

[](#license)

The scripts and documentation in this project are released under the [MIT License](LICENSE.md).

---

[![Logo of Van Ons](https://camo.githubusercontent.com/f233e4b012f8d6bded619dbeb286cf4d9c5fbe2789456e8c4495d3c0fae66b1f/68747470733a2f2f6f70656e736f757263652e76616e2d6f6e732e6e6c2f66696c65732f636f772e706e67)](https://van-ons.nl/)

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance88

Actively maintained with recent releases

Popularity28

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 50.8% 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 ~14 days

Recently: every ~3 days

Total

44

Last Release

55d ago

Major Versions

v1.1.3 → v2.0.0-rc52025-11-14

v1.2.1 → v2.1.12026-01-21

v1.2.2 → v2.1.32026-02-23

v1.2.4 → v2.1.42026-02-26

v1.2.5 → v2.2.52026-03-19

### Community

Maintainers

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

---

Top Contributors

[![dnwjn](https://avatars.githubusercontent.com/u/57711725?v=4)](https://github.com/dnwjn "dnwjn (126 commits)")[![dangelodelano](https://avatars.githubusercontent.com/u/26794861?v=4)](https://github.com/dangelodelano "dangelodelano (61 commits)")[![mauricewijnia](https://avatars.githubusercontent.com/u/8679682?v=4)](https://github.com/mauricewijnia "mauricewijnia (37 commits)")[![dangelobhva](https://avatars.githubusercontent.com/u/92536734?v=4)](https://github.com/dangelobhva "dangelobhva (7 commits)")[![KianAcquoy](https://avatars.githubusercontent.com/u/118724608?v=4)](https://github.com/KianAcquoy "KianAcquoy (7 commits)")[![JesseAlaerds](https://avatars.githubusercontent.com/u/12842801?v=4)](https://github.com/JesseAlaerds "JesseAlaerds (5 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![Boefjim](https://avatars.githubusercontent.com/u/16748131?v=4)](https://github.com/Boefjim "Boefjim (1 commits)")

---

Tags

attachmentseloquentfilamentlaravellaraveleloquentmodelsattachmentsfilament

###  Code Quality

Static AnalysisPHPStan

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[relaticle/custom-fields

User Defined Custom Fields for Laravel Filament

15828.6k](/packages/relaticle-custom-fields)[mopo922/laravel-treats

A collection of goodies for Laravel 5.

108451.6k1](/packages/mopo922-laravel-treats)[okeonline/filament-archivable

A filament plugin to use archivable models

208.1k](/packages/okeonline-filament-archivable)[pursehouse/modeler-laravel-eloquent

Generate model classes for Eloquent in Laravel

112.4k](/packages/pursehouse-modeler-laravel-eloquent)[martinpetricko/filament-restore-or-create

FilamentPHP package that adds ability to check for similar deleted records and restore them instead of creating new ones.

112.3k](/packages/martinpetricko-filament-restore-or-create)

PHPackages © 2026

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