title: Is it possible to use a model in it's own factory in a Laravel project?
body: <p>My team is building a project using laravel for the server code. Early on we were going to use models to manage some of the images used in the project, but we didn't have the images from the client yet. So we built out the models and used a laravel factory and faker to create fake images for testing. </p>
  
  <p>A month later (and many test cases later) we have the actual images from the client. I added the images to the project, created structural database seeders to populate the data needed for the database, and wrote out unit tests for the model to confirm it works. </p>
  
  <p>The issue is that now some of the tests are failing because the factory we're using for the image model still uses factory and faker. Anywhere where we need to look for a specific file using the model we get fails from the fake data provide by faker. </p>
  
  <p>I thought "well that's fine, I can just switch out the fake data in the factory for randomized data from the actual model". The problem I'm running into now is that when I try to use the actual model within the factory function, the model class only gets provided as a factory: </p>
  
  <p><a href="https://i.stack.imgur.com/sxLsh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sxLsh.png" alt="getting the class of the model"></a></p>
  
  <p>I know there's a good reason for this happening behind the scenes, I'm just wondering if there's a way of getting around it. If it's possible to use the actual model in the factory it would prevent me from having to rewrite a <em>lot</em> of test cases to swap out the factory for the actual model. It also seems like this would be a really convenient way of being able to do feature testing for items that you know will exist but don't have the actual assets for yet. </p>
  
  <p>Is there a way around this or should I plan on buckling down and refactoring my tests? </p>