From 1fd2774d77dca271621df4456f4aa61eb3f012d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20=C3=87ak=C4=B1rel?= Date: Wed, 22 Jan 2020 00:37:05 +0300 Subject: [PATCH] Use factories directly --- database/seeds/SampleData.php | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/database/seeds/SampleData.php b/database/seeds/SampleData.php index 8183449b1..359cde306 100755 --- a/database/seeds/SampleData.php +++ b/database/seeds/SampleData.php @@ -36,25 +36,11 @@ class SampleData extends Seeder $count = $this->command->option('count'); - for ($i = 0; $i < $count; $i++) { - $this->dispatch(new CreateContact(factory(Contact::class)->raw())); - } - - for ($i = 0; $i < $count; $i++) { - $this->dispatch(new CreateItem(factory(Item::class)->raw())); - } - - for ($i = 0; $i < $count; $i++) { - $this->dispatch(new CreateAccount(factory(Account::class)->raw())); - } - - for ($i = 0; $i < $count; $i++) { - $this->dispatch(new CreateBill(factory(Bill::class)->state('items')->raw())); - } - - for ($i = 0; $i < $count; $i++) { - $this->dispatch(new CreateInvoice(factory(Invoice::class)->state('items')->raw())); - } + factory(Contact::class, (int)$count)->create(); + factory(Item::class, (int)$count)->create(); + factory(Account::class, (int)$count)->create(); + factory(Bill::class, (int)$count)->create(); + factory(Invoice::class, (int)$count)->create(); for ($i = 0; $i < $count; $i++) { $amount = $faker->randomFloat(2, 1, 1000);