Daniel-Pablo's avatar

seed a seeder

Hi, community of laravel, i am trying to seed a created seeder but I dont know how to do it some help please:

php artisan migrate:fresh --seed // this command seed all my database but just pull up this file = DatabaseSeeder

I got other file called Codex Seeder but I dont have a clue how to call migrate fresh --seed and call all my seed files to seed the database... thanks in advance

0 likes
6 replies
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

You need to add them to your Database seeder class in the run method (replace with your own seeder names)

/**
 * Run the database seeds.
 *
 * @return void
 */
public function run()
{
    $this->call([
        UsersTableSeeder::class,
        PostsTableSeeder::class,
        CommentsTableSeeder::class,
    ]);
}
1 like
Daniel-Pablo's avatar

Thanks @sinnbeck you know a lot of laravel!! this code gets my seeders running thanks a lot again.

Sinnbeck's avatar

Happy to help. I work with it every day. Keep it up and you will get these things down soon :)

1 like
Daniel-Pablo's avatar

Thanks a lot, I am new and you seem to have a lot of experience!!, with all frameworks outside, do you think laravel is the best framework for developing? If yes why you prefer this one :) why is it better...

Sinnbeck's avatar

Well it is really well documented, there are tons of packages to extend it. It is even quite easy to make your own.

It is easy to learn. I taught a colleague laravel from scratch, and he never even used php before (he used python before).

I also like that I can get a project up and running in no time. There is scaffolding in place for most things.

1 like
Daniel-Pablo's avatar

Thanks for letting me know, this encourages me a lot to keep on!!! One day I hope to be level 50 like you.

Please or to participate in this conversation.