funkman85's avatar

Lumen 5.5 Seeder Issue

I created a new project using lumen 5.5 to test out JWT. While running the seeder, the users table get populated correctly. However, any other class throws an error saying:

[Symfony\Component\Debug\Exception\FatalThrowableError] Class 'App\Patient' not found

[Symfony\Component\Debug\Exception\FatalThrowableError] Class 'App\Purchase' not found

I've run composer dump-autoload but it still does not help.

Here is the code in the ModelFactory.php:

$factory->define(App\Patient::class, function (Faker\Generator $faker) { return [ 'name' => $faker->name, 'email' => $faker->unique()->email, 'password' => app('hash')->make('hello123'), ]; });

$factory->define(App\User::class, function (Faker\Generator $faker) { return [ 'name' => $faker->name, 'email' => $faker->unique()->email, 'password' => app('hash')->make('hello123'), ]; });

$factory->define(App\Purchase::class, function (Faker\Generator $faker) { return [ 'name' => $faker->name, 'email' => $faker->unique()->email, ]; });

Here is the code for the DatabaseSeeder.php

$this->call(UsersTableSeeder::class); $this->call(PurchasesTableSeeder::class); $this->call(PatientsTableSeeder::class);

The code for UsersTableSeeder.php factory(App\User::class, 10)->create();

The code for PatientsTableSeeder.php factory(App\Patient::class, 10)->create();

What am i doing wrong here?

0 likes
1 reply
funkman85's avatar

Figured it out. Need to create the models. User model is available by default hence the seeder ran fine.

For others I had to create the models. make:model command does not exist in Lumen. It throws up error:

Command "make:model" is not defined. Did you mean one of these? make:migration make:seeder

So you'll need to manually add the model.

Please or to participate in this conversation.