factory(App\Models\Team::class)->create()->id instead?
Sep 14, 2020
8
Level 3
Laravel 8 Team::factory() not found
I'm using the following in my UserFactory:
public function definition()
{
return [
'first_name' => $this->faker->firstName,
'last_name' => $this->faker->lastName,
// 'name' => $this->faker->name,
'email' => $this->faker->unique()->safeEmail,
'email_verified_at' => now(),
'password' => 'yIXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10),
'current_team_id' => Team::factory()
];
}
When run the seeder, I get the following error:
BadMethodCallException
Call to undefined method App\Models\Team::factory()
Any thoughts? This seems so silly, but it's frustrating me.
Level 3
make sure your user class has the trait HasFactory:
use HasFactory;
4 likes
Please or to participate in this conversation.