Laravel, Call to undefined function Database\Seeders\factory()

后端 未结 5 1431
说谎
说谎 2021-01-05 07:46

I get the title error when I run command:

php artisan db:seed

My screenshot:

I have no idea where this problem comes from. I was sear

5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-05 08:27

    All suggestions that were mentioned here are correct. However, you must run composer require laravel/legacy-factories in order for the code to run if you're using Laravel 8. In case you get an error that says Class 'Database\Factories\ArticleFactory' not found then make sure you have class ArticleFactory extends Factory and not ModalFactory. And make sure you're using HasFactory in the Article Model like here.

提交回复
热议问题