load Models defined in parent classes
This commit is contained in:
parent
0503b85c28
commit
eb0057963c
1 changed files with 11 additions and 1 deletions
|
|
@ -328,6 +328,15 @@
|
||||||
if(!is_array($models)) {
|
if(!is_array($models)) {
|
||||||
$models = array($models);
|
$models = array($models);
|
||||||
}
|
}
|
||||||
|
// Models of parent classes
|
||||||
|
$parent = $this;
|
||||||
|
while($parent = get_parent_class($parent))
|
||||||
|
{
|
||||||
|
$properties = get_class_vars($parent);
|
||||||
|
if(array_key_exists('models', $properties)) {
|
||||||
|
$models = array_merge($models, $properties['models']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Load Models
|
// Load Models
|
||||||
foreach($models as &$model)
|
foreach($models as &$model)
|
||||||
|
|
@ -337,7 +346,8 @@
|
||||||
Model::load($model);
|
Model::load($model);
|
||||||
|
|
||||||
// Construct Model
|
// Construct Model
|
||||||
$this->$model = Model::factory($model);
|
$modelName = ucfirst(strtolower($model));
|
||||||
|
$this->$modelName = Model::factory($model);
|
||||||
}
|
}
|
||||||
catch(\nre\exceptions\ModelNotValidException $e) {
|
catch(\nre\exceptions\ModelNotValidException $e) {
|
||||||
if($explicit) {
|
if($explicit) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue