/** * Translates a column to its corresponding property. * * @param string $column * @return string|null */ public function columnToProperty($column) { $map = $this->definition->getColumnMap(); if (isset($map[$column])) { return $column; } return array_search($column, $map, true) ?: null; }
/** * Asserts the key is valid for the related model. */ protected function assertValidForeignKey($key) { if (!in_array($key, $this->relatedDefinition->getColumnMap(), true)) { throw new InvalidArgumentException("Invalid key '{$key}' for '{$this->relatedDefinition->getName()}'"); } }