PHP Error: Class 'Database\Factories\MyFactory' not found
I am using Laravel 8 and not upgraded from Laravel 7.
I have a model in Models/MyModel
and I created a factory for it
when I run App\Models\MyModel::factory()->create(), I get:
PHP Error: Class 'Database\Factories\MyFactory' not found
The files exist
In factory class you must define $model property with corresponding model. In your case:
class MyFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = MyModel::class;
}
@knubbe Yes! I came here to say that I ran composer dump-autoload and it worked but you just said it as well, thank you!
Please or to participate in this conversation.