29 lines
830 B
PHP
29 lines
830 B
PHP
<?php
|
|
|
|
namespace App\Integrations\Whmcs\Extractors;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\LazyCollection;
|
|
|
|
class InvoiceExtractor
|
|
{
|
|
public function extract(): LazyCollection
|
|
{
|
|
return DB::connection('whmcs')->table('tblinvoices')->orderBy('id')->cursor();
|
|
}
|
|
|
|
/**
|
|
* Line items for a single invoice (tblinvoiceitems has no per-invoice cursor of its own,
|
|
* items are pulled per-invoice while its job runs).
|
|
*/
|
|
public function items(int $invoiceId): \Illuminate\Support\Collection
|
|
{
|
|
return DB::connection('whmcs')->table('tblinvoiceitems')->where('invoiceid', $invoiceId)->get();
|
|
}
|
|
|
|
public function orderIdFor(int $invoiceId): ?int
|
|
{
|
|
return DB::connection('whmcs')->table('tblorders')->where('invoiceid', $invoiceId)->value('id');
|
|
}
|
|
}
|