Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

factory error while installing in laravel 9 #174

Open
malozaibi opened this issue Sep 8, 2022 · 1 comment
Open

factory error while installing in laravel 9 #174

malozaibi opened this issue Sep 8, 2022 · 1 comment

Comments

@malozaibi
Copy link

Describe the bug
I get Target class [Illuminate\Database\Eloquent\Factory] does not exist. error while installing in Laravel 9.

Laravel Version
Laravel 9

@jigumany
Copy link

Use this solution

!!!the loadFactoriesFrom method should not be used, it's deprecated and it will be removed from Laravel in a future version!!!

What you should do, is overwrite the newFactory() method, that the HasFactory trait provides, and just register the factory there. I would be happier for a more "global" solution but this seems to be a good solution and doing it the way laravel intended it to. Hacking stuff will bite you in the future :)

/**

  • Create a new factory instance for the model.
  • @return Factory
    */
    protected static function newFactory(): Factory
    {
    return FactoryClass::new();
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants