PHPackages                             lukam/smart-seeder - 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. lukam/smart-seeder

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

lukam/smart-seeder
==================

Package to make handling of the seeder files easier by adding the commands to create, run, and rollback seed files

0.1.0-alpha(7y ago)03.8kMITPHPPHP &gt;=7.1.3

Since Mar 21Pushed 7y ago1 watchersCompare

[ Source](https://github.com/luka-mladenovic/laravel-smart-seeder)[ Packagist](https://packagist.org/packages/lukam/smart-seeder)[ RSS](/packages/lukam-smart-seeder/feed)WikiDiscussions master Synced 1mo ago

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

Smart seeder
============

[](#smart-seeder)

About
-----

[](#about)

The goal of the package is to make handling of the seeder files easier by adding the commands to create, run, check status and revert the ran seed files.

This is achieved by reusing the existing Migration package and adapting it to work with seed files.

Requirements
------------

[](#requirements)

The package works with Laravel version 5.6+.

Compatibility with existing seed files
--------------------------------------

[](#compatibility-with-existing-seed-files)

The existing seed files are not yet compatible with this package.

- When the package [seed file is created](#make) using the `php artisan seed:make` command the filename is prefixed with a date timestamp to ensure that the seed files are ran in a correct order.
- Refreshing the migrations with the `--seed` parameter will still call the `db:seed` command to seed the files which is not a part of this package.

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

[](#installation)

Install the package using Composer:

```
composer require lukam/smart-seeder

```

Configuration
-------------

[](#configuration)

By default the seeder uses `seeds` table to keep track of files.

To change the table, open the `config\database.php` file and add the `seeds` entry with the table name.

```
'seeds' => 'seed_table_name',
```

Commands
--------

[](#commands)

### Install

[](#install)

`php artisan seed:install`

This command will be executed the first time you use the `run` command.

This will create the seeder repository and database table. The table keeps track of which seed files have already been run.

### Status

[](#status)

`php artisan seed:status`

Show status of each seed file.

```
+------+-----------------------------+-------+
| Ran? | Seed                        | Batch |
+------+-----------------------------+-------+
| Y    | 2019_03_18_155332_users     | 1     |
| N    | 2019_03_19_184525_documents |       |
+------+-----------------------------+-------+

```

### Make

[](#make)

`php artisan seed:make filename`

Creates a new database seeder file inside the `database\seeds` folder.

To ensure that the seed files are run in the correct order a timestamp is prefixed to the filename.

The seed file now also contains the `revert` method which enables you to delete data from a table when rolling back the seeds. For more information see the [revert method](#revert-method) section.

### Run

[](#run)

`php artisan seed:run`

Run the database seeders.

### Rollback

[](#rollback)

`php artisan seed:rollback`

Rollback last run seeder files.

### Reset

[](#reset)

`php artisan seed:reset`

Rollback all seeder files.

### Refresh

[](#refresh)

`php artisan seed:refresh`

Rollback and re-run all seeder files.

Revert method
-------------

[](#revert-method)

In some cases you may want to delete or update the table data when a seed is rolled back. This can be done using the `revert` method. The method should contain the query that will be executed when the seed file is rolled back.

```
