load Models defined in parent classes
This commit is contained in:
parent
23346a78b5
commit
604e7c9bba
1 changed files with 11 additions and 1 deletions
|
@ -328,6 +328,15 @@
|
|||
if(!is_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
|
||||
foreach($models as &$model)
|
||||
|
@ -337,7 +346,8 @@
|
|||
Model::load($model);
|
||||
|
||||
// Construct Model
|
||||
$this->$model = Model::factory($model);
|
||||
$modelName = ucfirst(strtolower($model));
|
||||
$this->$modelName = Model::factory($model);
|
||||
}
|
||||
catch(\nre\exceptions\ModelNotValidException $e) {
|
||||
if($explicit) {
|
||||
|
|
Loading…
Reference in a new issue