client->listRecords($this->table(), [ 'order' => 'customer_code.desc.nullslast', 'limit' => 1, 'select' => 'customer_code', ])[0]['customer_code'] ?? null; preg_match('/(\d+)$/', (string) $last, $matches); return sprintf('CUST-%04d', ((int) ($matches[1] ?? 0)) + 1); } /** @return array id => "CUST-0001 — Nama" */ public function optionsForSelect(): array { return collect($this->client->listRecords($this->table(), [ 'select' => 'id,customer_code,name', 'order' => 'customer_code.asc', 'limit' => 500, ])) ->mapWithKeys(fn (array $row): array => [$row['id'] => trim(($row['customer_code'] ?? '').' — '.($row['name'] ?? ''), ' —')]) ->all(); } }