diff --git a/database/factories/AccountFactory.php b/database/factories/AccountFactory.php new file mode 100644 index 0000000..9b6d2ce --- /dev/null +++ b/database/factories/AccountFactory.php @@ -0,0 +1,15 @@ +define(App\Models\Account::class, function (Faker $faker) { + return [ + 'id'=>1, + ]; +}); + +$factory->afterMaking(App\Models\Account::class, function ($service,$faker) { + $country = factory(App\Models\Country::class)->make(); + $service->setRelation('country',$country); + $service->country_id = $country->id; +}); \ No newline at end of file diff --git a/database/factories/CountryFactory.php b/database/factories/CountryFactory.php new file mode 100644 index 0000000..48aba33 --- /dev/null +++ b/database/factories/CountryFactory.php @@ -0,0 +1,14 @@ +define(App\Models\Country::class, function (Faker $faker) { + return [ + 'id'=>1222, + ]; +}); + +$factory->afterMaking(App\Models\Country::class, function ($service,$faker) { + $taxes = factory(App\Models\Tax::class,1)->make(); + $service->setRelation('taxes',$taxes); +}); \ No newline at end of file diff --git a/database/factories/ServiceFactory.php b/database/factories/ServiceFactory.php index 6be4c7f..de49787 100644 --- a/database/factories/ServiceFactory.php +++ b/database/factories/ServiceFactory.php @@ -4,16 +4,18 @@ use Faker\Generator as Faker; $factory->define(App\Models\Service::class, function (Faker $faker) { return [ - 'account_id'=>1, 'active'=>1, ]; }); $factory->afterMaking(App\Models\Service::class, function ($service,$faker) { $product = factory(App\Models\Product::class)->make(); - $service->setRelation('product',$product); $service->product_id = $product->id; + + $account = factory(App\Models\Account::class)->make(); + $service->setRelation('account',$account); + $service->account_id = $account->id; }); // Weekly diff --git a/database/factories/TaxFactory.php b/database/factories/TaxFactory.php new file mode 100644 index 0000000..0b178fe --- /dev/null +++ b/database/factories/TaxFactory.php @@ -0,0 +1,11 @@ +define(App\Models\Tax::class, function (Faker $faker) { + return [ + 'id'=>1, + 'rate'=>0.1, + 'description'=>'GST', + ]; +}); \ No newline at end of file