Added column = property handling for mapping

This commit is contained in:
2022-10-10 17:32:34 -03:00
parent 0a9bed1735
commit fe67519682
2 changed files with 10 additions and 1 deletions

View File

@ -109,6 +109,9 @@ abstract class Repository implements RepositoryInterface
return $mapping->column;
}
}
if (in_array($property, $this->getColumns())) {
return $property;
}
throw new \InvalidArgumentException("Property {$property} not found in mapping in " . get_called_class());
}
public function findPropertyByColumn(string $column): string
@ -118,6 +121,9 @@ abstract class Repository implements RepositoryInterface
return $mapping->property;
}
}
if (in_array($column, $this->getProperties())) {
return $column;
}
throw new \InvalidArgumentException("Column {$column} not found in mapping in " . get_called_class());
}
@ -251,6 +257,9 @@ abstract class Repository implements RepositoryInterface
} catch (\InvalidArgumentException $e) {
continue;
}
if (isset($data[$column])) {
continue;
}
$m = $this->getMethod($property);
if (!method_exists($model, $m)) {
continue;

View File

@ -215,7 +215,7 @@ interface Repository
public function fillData(Model $model, array $data): Model;
/**
* Fill data array with Model values
* Fill data array with Model values. Accepts a preset data array
* @param Model $model
* @param array $data
* @return array