'required|string|max_length[9]', ]; protected $useTimestamps = false; private array $manualPaymentColumns = []; public function __construct(?ConnectionInterface $db = null, ?ValidationInterface $validation = null) { parent::__construct($db, $validation); $this->manualPaymentColumns = $this->getTableColumns($this->table); $this->allowedFields = array_values(array_filter( $this->allowedFields, fn (string $field): bool => in_array($field, $this->manualPaymentColumns, true) )); foreach (array_keys($this->validationRules) as $field) { if (!in_array($field, $this->allowedFields, true)) { unset($this->validationRules[$field]); } } } private function getTableColumns(string $table): array { try { return $this->db->getFieldNames($table); } catch (\Throwable $e) { log_message('error', '[ManualPaymentModel] Could not read table columns for {table}: {error}', [ 'table' => $table, 'error' => $e->getMessage(), ]); return []; } } }