2017 © Pedro Peláez
 

library laravel-cli-seeder

Generate schema based test data from the cli.

image

digital-drifter/laravel-cli-seeder

Generate schema based test data from the cli.

  • Tuesday, July 3, 2018
  • by digital-drifter
  • Repository
  • 1 Watchers
  • 0 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Laravel CLI Seeder

A (semi) intelligent utility to generate test data quickly., (*1)

About

The idea behind this package is generate test data based on a table that acts as the central reference point. Often times, applications will have a table that effectively serves as the root node for a relationship graph. For example, a typical multi-tenancy application will define a tenants, accounts, customers, etc. table which other tables define a foreign relationship with., (*2)

Using tenants as the example table, there could be users, settings, and posts tables which each have a tenant_id. By setting the Tenant model as the parent model in the configuration, this package will query for all tenants and prompt to select one for the generation process. Anytime a column name tenant_id is encountered, the selected tenant's primary key will be used., (*3)

In addition, when other foreign keys are detected, it will attempt to only use those which are assigned to the tenant, as well., (*4)

Installation

composer require digital-drifter/laravel-cli-seeder

Usage

php artisan cli-seeder:generate

Configuration

config/cli-seeder.php, (*5)

<?php

use App\Models\Tenant;

return [
    /**
     * Decide on a parent model as explained above.
     * Set the primary key column name.
     * Set the column used for display purposes.
     */
    'parent' => [
        'model' => Tenant::class,
        'primary_key'  => 'id',
        'display_name' => 'name'
    ]
];

The Versions

03/07 2018

dev-master

9999999-dev

Generate schema based test data from the cli.

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

The Development Requires

by Digital Drifter

database laravel generator faker seed