I am not sure, but there is a way to solve this issue is by adding the following line on top of the class.
/** @var \Illuminate\Database\Eloquent\Factory $factory */
So, it will be like this-
<?php
use Faker\Generator as Faker;
/** @var \Illuminate\Database\Eloquent\Factory $factory */
$factory->define(App\User::class, function (Faker $faker) {
return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'password' => 'y$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
'remember_token' => str_random(10),
];
});
Ref: https://stackoverflow.com/questions/57847479/factory-undefined-variable