PHPackages                             krzysztofrewak/laravel-conditional-seeders - 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. krzysztofrewak/laravel-conditional-seeders

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

krzysztofrewak/laravel-conditional-seeders
==========================================

Run Laravel seeders conditionally.

1.0.0(5y ago)93MITPHPPHP ^7.3

Since Sep 13Pushed 5y ago1 watchersCompare

[ Source](https://github.com/krzysztofrewak/laravel-conditional-seeders)[ Packagist](https://packagist.org/packages/krzysztofrewak/laravel-conditional-seeders)[ RSS](/packages/krzysztofrewak-laravel-conditional-seeders/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/3e7789d0c5e334ba8ad554713338369f41644c79e5c654429ed0c194e89b9503/68747470733a2f2f706f7365722e707567782e6f72672f6b727a79737a746f66726577616b2f6c61726176656c2d636f6e646974696f6e616c2d736565646572732f762f737461626c65)](https://packagist.org/packages/krzysztofrewak/laravel-conditional-seeders) [![Total Downloads](https://camo.githubusercontent.com/6ca7b8a6e602d02f8f94893e4df25d4a4ef25a6828b3ae4637e0f448862cdd91/68747470733a2f2f706f7365722e707567782e6f72672f6b727a79737a746f66726577616b2f6c61726176656c2d636f6e646974696f6e616c2d736565646572732f646f776e6c6f616473)](https://packagist.org/packages/krzysztofrewak/laravel-conditional-seeders) [![License](https://camo.githubusercontent.com/1903050b176272577a60d2173cb70aa556e4b1af67fd140244375c8b0a91e90d/68747470733a2f2f706f7365722e707567782e6f72672f6b727a79737a746f66726577616b2f6c61726176656c2d636f6e646974696f6e616c2d736565646572732f6c6963656e7365)](https://packagist.org/packages/krzysztofrewak/laravel-conditional-seeders)

About
-----

[](#about)

Relatively often I needed to put some logic into seeders and run them accordingly to some conditions (eg. I didn't want to duplicate or overwrite some data, I just wanted to run it once, I just wanted to run it only on certain environment, etc.). Putting these conditions into `run()` method was making these seeders less readable and putting them into `DatabaseSeeder` could be dangerous enough (because someone could just ran it from the console).

I added a method `authorize()` to an abstract `Seeder`. Method is returning `true` by default, so it should be completely backward compatible with existing seeders. Conditionally disabling any seeder from running is extremely easy:

```
class DisabledTestSeeder extends Seeder
{
    public function run(): void
    {
        // (...)
    }

    protected function authorize(): bool
    {
        return false;
    }
}
```

Of course, it can look like this (to ensure that it will fire only when users table would be empty):

```
protected function authorize(): bool
{
    return User::count() === 0;
}
```

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

[](#installation)

Include this package with Composer:

```
composer require krzysztofrewak/laravel-conditional-seeders ^1.0
```

Now you can switch base class of your seeders in `database/seeders` directory to `\KrzysztofRewak\ConditionalSeeder\ConditionalSeeder`. By overwriting `authorize()` method you can conditionally switch on/off seeder in question.

Please remember to change base class of `DatabaseSeeder` to `\KrzysztofRewak\ConditionalSeeder\ConditionalSeeder` too. Without it, it won't work properly.

###  Health Score

24

—

LowBetter than 30% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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

Unknown

Total

1

Last Release

2166d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10898728?v=4)[Krzysztof Rewak](/maintainers/krzysztofrewak)[@krzysztofrewak](https://github.com/krzysztofrewak)

---

Top Contributors

[![krzysztofrewak](https://avatars.githubusercontent.com/u/10898728?v=4)](https://github.com/krzysztofrewak "krzysztofrewak (5 commits)")

---

Tags

laravelseeders

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/krzysztofrewak-laravel-conditional-seeders/health.svg)

```
[![Health](https://phpackages.com/badges/krzysztofrewak-laravel-conditional-seeders/health.svg)](https://phpackages.com/packages/krzysztofrewak-laravel-conditional-seeders)
```

###  Alternatives

[spatie/laravel-medialibrary

Associate files with Eloquent models

6.2k45.4M705](/packages/spatie-laravel-medialibrary)[laravel/ai

The official AI SDK for Laravel.

1.1k4.6M327](/packages/laravel-ai)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.6k31.8M162](/packages/laravel-cashier)[spatie/laravel-health

Monitor the health of a Laravel application

88212.7M189](/packages/spatie-laravel-health)[forjedio/inertia-table

Backend-driven dynamic tables for Laravel + Inertia.js

272.0k](/packages/forjedio-inertia-table)[masterix21/laravel-licensing

Laravel licensing package with polymorphic assignment to any model, activation keys, expirations/renewals, and seat control via LicenseUsage. Supports offline verification with public-key–signed tokens, a CLI to generate/rotate/revoke keys, and an extensible architecture via config and contracts.

1614.1k4](/packages/masterix21-laravel-licensing)

PHPackages © 2026

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