PHPackages                             swalbrun/filament-regex-import - 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. swalbrun/filament-regex-import

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

swalbrun/filament-regex-import
==============================

This Filament Plugin will enable you to import files to upsert models by matching columns via regex.

2.0.1(1y ago)3131[2 PRs](https://github.com/sWalbrun/filament-regex-import/pulls)MITPHPPHP ^8.2CI passing

Since May 12Pushed 1y ago1 watchersCompare

[ Source](https://github.com/sWalbrun/filament-regex-import)[ Packagist](https://packagist.org/packages/swalbrun/filament-regex-import)[ Docs](https://github.com/swalbrun/filament-regex-import)[ GitHub Sponsors](https://github.com/sWalbrun)[ RSS](/packages/swalbrun-filament-regex-import/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (19)Versions (8)Used By (0)

Filament Plugin for importing CSV and XLS files via regex
=========================================================

[](#filament-plugin-for-importing-csv-and-xls-files-via-regex)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d897a72e453511384ad9c0157ec4843dc7d4ebcbf9a50a1710ecaaf5c6fdbd4b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7377616c6272756e2f66696c616d656e742d72656765782d696d706f72742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/swalbrun/filament-regex-import)[![GitHub Tests Action Status](https://camo.githubusercontent.com/c9b4112ffb3113f9948d2a6ebd66de4c20aa85f9335b6aa8b1afec99dae7ae78/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7377616c6272756e2f66696c616d656e742d72656765782d696d706f72742f72756e2d74657374732e796d6c3f6272616e63683d6d61696e)](https://camo.githubusercontent.com/c9b4112ffb3113f9948d2a6ebd66de4c20aa85f9335b6aa8b1afec99dae7ae78/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7377616c6272756e2f66696c616d656e742d72656765782d696d706f72742f72756e2d74657374732e796d6c3f6272616e63683d6d61696e)[![](https://camo.githubusercontent.com/8861b14294a34306c5d99816d32993f5a6344fcce14d87ea7edaa855ecbf2faa/68747470733a2f2f636f6465636f762e696f2f67682f7357616c6272756e2f66696c616d656e742d72656765782d696d706f72742f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d39484730513035555732)](https://codecov.io/gh/sWalbrun/filament-regex-import)[![Total Downloads](https://camo.githubusercontent.com/2bb10b9b95bd15b8f8875fe9a8d11866e319a3cc56635bb62294c933cb22e6ff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7377616c6272756e2f66696c616d656e742d72656765782d696d706f72742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/swalbrun/filament-regex-import)

This Filament Plugin will enable you to import files to upsert models by matching columns via regex.

[![Page](https://private-user-images.githubusercontent.com/38902857/241363606-0c62bc8a-6608-4208-bb8c-3fc0cc48c003.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODE1NjIzMjEsIm5iZiI6MTc4MTU2MjAyMSwicGF0aCI6Ii8zODkwMjg1Ny8yNDEzNjM2MDYtMGM2MmJjOGEtNjYwOC00MjA4LWJiOGMtM2ZjMGNjNDhjMDAzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjA2MTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwNjE1VDIyMjAyMVom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](https://private-user-images.githubusercontent.com/38902857/241363732-3398d51f-41ef-4a2d-b42a-a132d07dee87.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODE1NjIzMjEsIm5iZiI6MTc4MTU2MjAyMSwicGF0aCI6Ii8zODkwMjg1Ny8yNDEzNjM3MzItMzM5OGQ1MWYtNDFlZi00YTJkLWI0MmEtYTEzMmQwN2RlZTg3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjA2MTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwNjE1VDIyMjAyMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE1MTExZGMxODgzMmYyMDRjMjU4NGI4MjI5MzZjZmM0MzBiNTY4NDUxODk1ODc4NThjYjljN2U5ZDNiYzgzNjcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JnJlc3BvbnNlLWNvbnRlbnQtdHlwZT1pbWFnZSUyRnBuZyJ9.OEHpoV5JqSxg7-FkKneB5l1NRNGQNNuBDkhC9Puwta8)](https://private-user-images.githubusercontent.com/38902857/241363732-3398d51f-41ef-4a2d-b42a-a132d07dee87.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODE1NjIzMjEsIm5iZiI6MTc4MTU2MjAyMSwicGF0aCI6Ii8zODkwMjg1Ny8yNDEzNjM3MzItMzM5OGQ1MWYtNDFlZi00YTJkLWI0MmEtYTEzMmQwN2RlZTg3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjA2MTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwNjE1VDIyMjAyMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE1MTExZGMxODgzMmYyMDRjMjU4NGI4MjI5MzZjZmM0MzBiNTY4NDUxODk1ODc4NThjYjljN2U5ZDNiYzgzNjcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JnJlc3BvbnNlLWNvbnRlbnQtdHlwZT1pbWFnZSUyRnBuZyJ9.OEHpoV5JqSxg7-FkKneB5l1NRNGQNNuBDkhC9Puwta8)

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

[](#installation)

You can install the package via composer:

```
composer require swalbrun/filament-regex-import
```

Create a mapper using the make command

```
php artisan filament:make-filament-import-mapper UserMapper
```

You can publish the config file with:

```
php artisan vendor:publish --tag="filament-regex-import-config"
```

This is the contents of the published config file:

```
return [
    'accepted_mimes' => [
        'application/vnd.ms-excel',
        'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
        'text/csv',
        'text/plain',
        'csv',
    ],
    'mappers' => [
    ],
    'navigation_group' => 'Import',
];
```

You can publish the translation file with:

```
php artisan vendor:publish --tag="filament-regex-import-translations"
```

Features
--------

[](#features)

### Matching header columns with configured regex

[](#matching-header-columns-with-configured-regex)

Matches given mappers' regex with model columns

UsernameEMailSebastianJohn```
 public function propertyMapping(): Collection
    {
        return collect([
            'name' => '/(user|first|last)?name)/i',
            'email' => '/(E(-|_)?)?Mail/i',
        ]);
    }
```

### Detecting overlapping regexes

[](#detecting-overlapping-regexes)

Fails in case two regexes are matching the same column.

### Upserting models via unique keys

[](#upserting-models-via-unique-keys)

Creates or updates models taking care of the given unique columns

```
public function uniqueColumns(): array
    {
        return [
            'email',
        ];
    }
```

### Relating models

[](#relating-models)

Call hooks for relating found models. The hooks will get called in case **all** hooks arguments models have been found

```
public function relatingClosures(): Collection
    {
        return collect([
            fn (User $user, Role $role) => $user->roles()->saveMany([$role]),
            fn (User $user) => event(new UserImported($user)),
            // Only gets called if a user, role and post with the matching type has been found by import
            function (User $user, Role $role, Post $post)  {
                if ($role->is('user')) {
                    $user->post()->associate($post)->save();
                }
            };
        ]);
    }
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Sebastian Walbrun](https://github.com/sWalbrun)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance43

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 87.5% 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 ~176 days

Total

5

Last Release

447d ago

Major Versions

0.2.1 → 2.0.02025-04-14

PHP version history (2 changes)0.1.0PHP ^8.0

2.0.0PHP ^8.2

### Community

Maintainers

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

---

Top Contributors

[![sWalbrun](https://avatars.githubusercontent.com/u/38902857?v=4)](https://github.com/sWalbrun "sWalbrun (28 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")

---

Tags

laravelsWalbrunfilament-regex-import

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/swalbrun-filament-regex-import/health.svg)

```
[![Health](https://phpackages.com/badges/swalbrun-filament-regex-import/health.svg)](https://phpackages.com/packages/swalbrun-filament-regex-import)
```

###  Alternatives

[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[stephenjude/filament-jetstream

A Laravel starter kit built with Filament inspired by Jetstream.

17760.2k3](/packages/stephenjude-filament-jetstream)[stephenjude/filament-debugger

About

104162.2k2](/packages/stephenjude-filament-debugger)[wnx/laravel-backup-restore

A package to restore database backups made with spatie/laravel-backup.

213421.4k2](/packages/wnx-laravel-backup-restore)[croustibat/filament-jobs-monitor

Background Jobs monitoring like Horizon for all drivers for FilamentPHP

274327.2k9](/packages/croustibat-filament-jobs-monitor)

PHPackages © 2026

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