Files

27 lines
769 B
PHP

<?php
namespace App\Integrations\Whmcs\Extractors;
use App\Integrations\Whmcs\Support\SyncedLegacyIds;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\LazyCollection;
class OrderItemExtractor
{
/**
* Each `tblhosting` row (a provisioned service instance) is the closest WHMCS equivalent
* of an order line item — WHMCS orders have no real line-item table of their own.
*/
public function extract(bool $missingOnly = false): LazyCollection
{
$rows = DB::connection('whmcs')->table('tblhosting')->orderBy('id')->cursor();
if (! $missingOnly) {
return $rows;
}
$synced = SyncedLegacyIds::of('order_items');
return $rows->reject(fn ($row) => isset($synced[$row->id]));
}
}