Files
portal-api/app/Integrations/Whmcs/Extractors/ClientExtractor.php
T

22 lines
533 B
PHP

<?php
namespace App\Integrations\Whmcs\Extractors;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\LazyCollection;
class ClientExtractor
{
public function extract(bool $missingOnly = false): LazyCollection
{
$rows = DB::connection('whmcs')->table('tblclients')->orderBy('id')->cursor();
if (! $missingOnly) {
return $rows;
}
$uuids = DB::table('customers')->pluck('uuid')->flip()->all();
return $rows->reject(fn ($row) => isset($uuids[$row->uuid]));
}
}