Level 73
Your factory is called AdminFactory not a UserFactory so you will have to rename that, and also make sure the namespace app/models/admin also is real folder structure and you use it as namespace on top of your class
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
after creating factory and seeder class for admin it shows me error as given below: Call to undefined method App\Models\admin\User::factory()
admin factory class
class AdminFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => 'Best Services',
'email' => '[email protected]',
'password' => bcrypt('password')
];
}
}
seeder class :
class AdminSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
User::factory()->count(1)->create();
}
}
databaseseeder class:
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*
* @return void
*/
public function run()
{
// \App\Models\User::factory(10)->create();
$this->call([
BlogCategorySeeder::class,
BlogTagSeeder::class,
AdminSeeder::class
]);
}
}
user model:
class User extends Model
{
use HasFactory;
protected $table = 'users';
}
Please or to participate in this conversation.