Added column = property handling for mapping
This commit is contained in:
@ -109,6 +109,9 @@ abstract class Repository implements RepositoryInterface
|
|||||||
return $mapping->column;
|
return $mapping->column;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (in_array($property, $this->getColumns())) {
|
||||||
|
return $property;
|
||||||
|
}
|
||||||
throw new \InvalidArgumentException("Property {$property} not found in mapping in " . get_called_class());
|
throw new \InvalidArgumentException("Property {$property} not found in mapping in " . get_called_class());
|
||||||
}
|
}
|
||||||
public function findPropertyByColumn(string $column): string
|
public function findPropertyByColumn(string $column): string
|
||||||
@ -118,6 +121,9 @@ abstract class Repository implements RepositoryInterface
|
|||||||
return $mapping->property;
|
return $mapping->property;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (in_array($column, $this->getProperties())) {
|
||||||
|
return $column;
|
||||||
|
}
|
||||||
throw new \InvalidArgumentException("Column {$column} not found in mapping in " . get_called_class());
|
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) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (isset($data[$column])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$m = $this->getMethod($property);
|
$m = $this->getMethod($property);
|
||||||
if (!method_exists($model, $m)) {
|
if (!method_exists($model, $m)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -215,7 +215,7 @@ interface Repository
|
|||||||
public function fillData(Model $model, array $data): Model;
|
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 Model $model
|
||||||
* @param array $data
|
* @param array $data
|
||||||
* @return array
|
* @return array
|
||||||
|
Reference in New Issue
Block a user