applied new scopes to factories

This commit is contained in:
denisdulici 2020-04-07 14:48:25 +03:00
parent 0f9ad51316
commit 663b1a5d6a
2 changed files with 2 additions and 6 deletions

View File

@ -23,9 +23,7 @@ $factory->define(Bill::class, function (Faker $faker) use ($company) {
$billed_at = $faker->dateTimeBetween(now()->startOfYear(), now()->endOfYear())->format('Y-m-d'); $billed_at = $faker->dateTimeBetween(now()->startOfYear(), now()->endOfYear())->format('Y-m-d');
$due_at = Date::parse($billed_at)->addDays(10)->format('Y-m-d'); $due_at = Date::parse($billed_at)->addDays(10)->format('Y-m-d');
$types = (string) setting('contact.type.vendor', 'vendor'); $contacts = Contact::vendor()->enabled()->get();
$contacts = Contact::type(explode(',', $types))->enabled()->get();
if ($contacts->count()) { if ($contacts->count()) {
$contact = $contacts->random(1)->first(); $contact = $contacts->random(1)->first();

View File

@ -24,9 +24,7 @@ $factory->define(Invoice::class, function (Faker $faker) use ($company) {
$invoiced_at = $faker->dateTimeBetween(now()->startOfYear(), now()->endOfYear())->format('Y-m-d'); $invoiced_at = $faker->dateTimeBetween(now()->startOfYear(), now()->endOfYear())->format('Y-m-d');
$due_at = Date::parse($invoiced_at)->addDays(setting('invoice.payment_terms'))->format('Y-m-d'); $due_at = Date::parse($invoiced_at)->addDays(setting('invoice.payment_terms'))->format('Y-m-d');
$types = (string) setting('contact.type.customer', 'customer'); $contacts = Contact::customer()->enabled()->get();
$contacts = Contact::type(explode(',', $types))->enabled()->get();
if ($contacts->count()) { if ($contacts->count()) {
$contact = $contacts->random(1)->first(); $contact = $contacts->random(1)->first();