I am having trouble figuring out if this package fits my use case. Previously I used [Laracasts\Testdummy]() and I am trying to replace it with something framework agnostic. At first glance this package looked like the solution to my problems. However, after attempting to integrate it I have run into issues. The problems I am having have to do with complex relationships.
For example in my application lets say I have 3 models:
<?php
use League\Factory\Facade as Factory;
Factory::define(Business::class, [
// ..... Many more attributes
"facebook_page_id" => 'factory|' . FacebookPage::class
]);
Factory::define(Restaurant::class, [
"biz_id" => "factory|" . Business::class,
// .... Many more attributes
"facebook_page_id" => "factory|" . FacebookPage::class
]);
Factory::define(FacebookPage::class, [
'facebook_page_id' => $faker->unqiue()->randomNumberBetween(0, 20000)
]);
So in this situation the way I created a restaurant in Laracasts\Testdummy in order to avoid creating multiple FacebookPages I would create a FacebookPage and pass the facebook_page_id to both the business and restaurant class like so.
I have had success with models that do not have relationships where I try to override it with the Factory::create method, however, for this example I get MySQL Error: Duplicate entry '5614' for key 'PRIMARY' for my FacebookPage model. So to me it seems like FactoryMuffin is still trying to save the relationship even though I am only passing an ID. Is this correct? I was wondering if what I am describing is possible?
I am having trouble figuring out if this package fits my use case. Previously I used [Laracasts\Testdummy]() and I am trying to replace it with something framework agnostic. At first glance this package looked like the solution to my problems. However, after attempting to integrate it I have run into issues. The problems I am having have to do with complex relationships.
For example in my application lets say I have 3 models:
So in this situation the way I created a restaurant in Laracasts\Testdummy in order to avoid creating multiple FacebookPages I would create a FacebookPage and pass the facebook_page_id to both the business and restaurant class like so.
I have had success with models that do not have relationships where I try to override it with the
Factory::create
method, however, for this example I getMySQL Error: Duplicate entry '5614' for key 'PRIMARY'
for my FacebookPage model. So to me it seems like FactoryMuffin is still trying to save the relationship even though I am only passing an ID. Is this correct? I was wondering if what I am describing is possible?