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