Seeding

Introduction

In general seeders in the Streams Platform work just like seeders in Laravel.

Creating Seeders

You can create a simple seeder like so:

<?php namespace Anomaly\ExampleModule;

use Anomaly\Streams\Platform\Database\Seeder\Seeder;
use Example\TestModule\Widget\Contract\WidgetRepositoryInterface;

class ExampleModuleSeeder extends Seeder
{

    protected $widgets;

    public function __construct(WidgetRepositoryInterface $widgets)
    {
        $this->widgets = $widgets;
    }

    public function run()
    {
        $this->widgets->create(
            [
                'en'           => [
                    'name' => 'Welcome',
                ],
                'slug'         => 'welcome',
                'enabled'      => true,
                'price'        => 100,
            ]
        );
    }
}

Running Seeders

You can run seeders in addons by providing the --addon option.

php artisan db:seed --addon=example.module.test