parfumix/laravel-smart-seed

一个laravel5 yaml播种器。

v1.0 2015-02-11 09:58 UTC

This package is auto-updated.

Last update: 2024-09-19 21:15:42 UTC


README

Join the chat at https://gitter.im/parfumix/laravel-smart-seed

安装

首先通过Composer安装此包。从终端运行以下命令

    composer require parfumix/laravel-smart-seed

Laravel集成

要在您的Laravel项目中设置此功能,您需要添加服务提供者。打开app/config/app.php,并在提供者数组中添加一个新项。

 'LaravelSeed\Laravel5SeedServiceProvider',

使用以下命令发布您的配置文件。

php artisan smart:install

添加新的源播种器。

要添加新源,您必须输入以下命令

php artisan smart:seed create user,page,news

每个名称都必须与现有的Eloquent模型相同。

要运行所有创建的播种器源,请输入

php artisan smart:seed run

设置配置文件

要添加新提供者,请转到app/seeds.php配置文件并添加提供者

 'providers' => array(
        'yaml' => array(
            'path'   => config_path('seeds/yaml'),
            
            #enter an provider which will create an seed resource and rn
            'class'  => LaravelSeed\Providers\YamlProvider::class,
            
            #or add closure functions
            'run' => function() {
              // run all your migrations from provider path
            },
            
            'create' => function($source, $class) {
              // create an resource seed
            }
        )
    )

设置默认提供者

要设置默认提供者,请转到app/seeds.php

  # enter an existing provider.
  'default' => 'yaml',

许可协议

Laravel智能播种器是开源软件,受MIT许可协议许可。