save($customerData)) { return $customerData[$this->primaryKey] ?? $this->getInsertID(); } } catch (ReflectionException $e) { log_message('error', 'Subscription upsert failed: ' . $e->getMessage()); } return false; } public function exists(?int $customerId): bool { if (!is_int($customerId) || $customerId < 1) { return false; } $builder = $this->db->table($this->table); $builder->where('customer_id', $customerId); return ($builder->countAllResults() === 1); } public function getByCustomerId(int $customerId): ?Subscription { if ($customerId < 1) { return null; } $result = $this->where('customer_id', $customerId)->first(); return $result instanceof Subscription ? $result : null; } }