Skip to content

Commit

Permalink
close mootensai#32
Browse files Browse the repository at this point in the history
Thanks!!
  • Loading branch information
mootensai committed Mar 30, 2017
1 parent 5c87ae9 commit 96c329a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions RelationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public function loadAll($POST, $skippedRelations = [])
if (array_filter($relPost)) {
/* @var $relObj ActiveRecord */
$relObj = (empty($relPost[$relPKAttr[0]])) ? new $relModelClass : $relModelClass::findOne($relPost[$relPKAttr[0]]);
if (is_null($relObj)) {
$relObj = new $relModelClass();
}
$relObj->load($relPost, '');
$container[] = $relObj;
}
Expand Down Expand Up @@ -326,14 +329,14 @@ public function getRelationData()
if ($method->name === 'deleteWithRelated') {
continue;
}
if (strpos($method->name, 'get') === false) {
if (strpos($method->name, 'get') !== 0) {
continue;
}
try {
$rel = call_user_func(array($this, $method->name));
if ($rel instanceof \yii\db\ActiveQuery) {
$name = lcfirst(str_replace('get', '', $method->name));
$stack[$name]['name'] = lcfirst(str_replace('get', '', $method->name));
$name = lcfirst(preg_replace('/^get/', '', $method->name));
$stack[$name]['name'] = lcfirst(preg_replace('/^get/', '', $method->name));
$stack[$name]['method'] = $method->name;
$stack[$name]['ismultiple'] = $rel->multiple;
$stack[$name]['modelClass'] = $rel->modelClass;
Expand Down

0 comments on commit 96c329a

Please sign in to comment.