Module - How to seed data?
Created 6 years ago by marceauka

Hi, I'm building a module with a stream. There's no documentation about seeding. I've try this in my CategorySeeder.php:

    protected $data = [
        [
            'name' => 'Foo',
            'slug' => 'foo'
        ],
        // ...
    ];

    public function run()
    {
        // "categories" is CategoryRepositoryInterface
        $this->categories->truncate();

        foreach ($this->data as $data) {
            $this->categories->create($data);
        }
    }

But when I call artisan addon:reinstall vendor.type.name --seed nothing happens.

ryanthompson  —  6 years ago

Close! Make sure your addon seeder is calling the subsequent stream seeders like this: https://github.com/anomalylabs/pages-module/tree/2.3/src

marceauka  —  6 years ago

Yeah, it works! Thank you ;p