Support the ongoing development of Laravel.io →
Database Testing
Last updated 1 year ago.
0

Bump. I also want to define my model factories in my package directory where my models live, not in my test app.

0

The framework basically combines any .php files in the database/factories folder.

To streamline things a little bit, I got rid of ModelFactory.php and created things like:

/database
  /factories
    UserFactory.php
    ProductFactory.php

Each of those files simply contains the $factory->define(...); line.

As for putting them elsewhere.. I don't know.. but all the magic seems to happen in Illuminate/Database/Eloquent/Factory.php in the construct function.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.