Support the ongoing development of Laravel.io →
Installation Database Packages
Last updated 2 years ago.
0

Found this post while looking for the solution, so adding this to help anyone else that needs it.

Your Seeder class was not namespace'd.

<?php

namespace PackageCompany\Package\Database\Seeds;

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{

then you can run

php artisan db:seed --class=PackageCompany\\Package\\Database\\Seeds\\DatabaseSeeder
Last updated 7 years ago.
0

Works with php artisan migrate:refresh && php artisan db:seed

Won't work with --seed, as no control over boot order with this code (inserts before tables are created).

/**
 * Register seeds.
 *
 * @param  string  $path
 * @return void
 */
protected function registerSeedsFrom($path)
{
    foreach (glob("$path/*.php") as $filename)
    {
        include $filename;
        $classes = get_declared_classes();
        $class = end($classes);

        $command = Request::server('argv', null);
        if (is_array($command)) {
            $command = implode(' ', $command);
            if ($command == "artisan db:seed") {
                Artisan::call('db:seed', ['--class' => $class]);
            }
        }

    }
}
0

Sign in to participate in this thread!

Eventy

Your banner here too?

ell ell Joined 3 Aug 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.