23 lines
566 B
PHP
23 lines
566 B
PHP
<?php
|
|
|
|
namespace App\Integrations\Whmcs\Extractors;
|
|
|
|
use App\Integrations\Whmcs\Support\SyncedLegacyIds;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\LazyCollection;
|
|
|
|
class OrderExtractor
|
|
{
|
|
public function extract(bool $missingOnly = false): LazyCollection
|
|
{
|
|
$rows = DB::connection('whmcs')->table('tblorders')->orderBy('id')->cursor();
|
|
if (! $missingOnly) {
|
|
return $rows;
|
|
}
|
|
|
|
$synced = SyncedLegacyIds::of('orders', true);
|
|
|
|
return $rows->reject(fn ($row) => isset($synced[$row->id]));
|
|
}
|
|
}
|