diff --git a/app/Http/Controllers/Portal/Invoices.php b/app/Http/Controllers/Portal/Invoices.php index 01d7b2a50..5c155662b 100644 --- a/app/Http/Controllers/Portal/Invoices.php +++ b/app/Http/Controllers/Portal/Invoices.php @@ -8,6 +8,7 @@ use App\Models\Common\Contact; use App\Models\Sale\Invoice; use App\Models\Setting\Category; use App\Models\Setting\Currency; +use App\Traits\Contacts; use App\Traits\Currencies; use App\Traits\DateTime; use App\Traits\Sales; @@ -17,7 +18,7 @@ use Illuminate\Support\Facades\URL; class Invoices extends Controller { - use DateTime, Currencies, Sales, Uploads; + use DateTime, Currencies, Sales, Uploads, Contacts; /** * Display a listing of the resource. @@ -52,7 +53,7 @@ class Invoices extends Controller $account_currency_code = Account::where('id', setting('default.account'))->pluck('currency_code')->first(); - $customers = Contact::type('customer')->enabled()->orderBy('name')->pluck('name', 'id'); + $customers = Contact::type($this->getCustomerTypes())->enabled()->orderBy('name')->pluck('name', 'id'); $categories = Category::type('income')->enabled()->orderBy('name')->pluck('name', 'id'); @@ -156,7 +157,7 @@ class Invoices extends Controller $account_currency_code = Account::where('id', setting('default.account'))->pluck('currency_code')->first(); - $customers = Contact::type('customer')->enabled()->pluck('name', 'id'); + $customers = Contact::type($this->getCustomerTypes())->enabled()->pluck('name', 'id'); $categories = Category::type('income')->enabled()->pluck('name', 'id'); diff --git a/database/factories/Bill.php b/database/factories/Bill.php index 47d3dc425..1141bdc1b 100644 --- a/database/factories/Bill.php +++ b/database/factories/Bill.php @@ -21,7 +21,9 @@ $factory->define(Bill::class, function (Faker $faker) use ($company) { $billed_at = $faker->dateTimeBetween(now()->startOfYear(), now()->endOfYear())->format('Y-m-d'); $due_at = Date::parse($billed_at)->addDays(10)->format('Y-m-d'); - $contacts = Contact::type('vendor')->enabled()->get(); + $types = (string) setting('contact.type.vendor', 'vendor'); + + $contacts = Contact::type(explode(',', $types))->enabled()->get(); if ($contacts->count()) { $contact = $contacts->random(1)->first(); diff --git a/database/factories/Invoice.php b/database/factories/Invoice.php index 84cfb9d0c..0f3c7b0bc 100644 --- a/database/factories/Invoice.php +++ b/database/factories/Invoice.php @@ -21,7 +21,9 @@ $factory->define(Invoice::class, function (Faker $faker) use ($company) { $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'); - $contacts = Contact::type('customer')->enabled()->get(); + $types = (string) setting('contact.type.customer', 'customer'); + + $contacts = Contact::type(explode(',', $types))->enabled()->get(); if ($contacts->count()) { $contact = $contacts->random(1)->first();