Added column = property handling for mapping
This commit is contained in:
@ -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;
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user