Skip to content

Commit

Permalink
fixes #19
Browse files Browse the repository at this point in the history
  • Loading branch information
mootensai authored Jul 8, 2016
1 parent 549231d commit b41ca3a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions RelationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ public function loadAll($POST, $skippedRelations = [])
/* @var $relObj ActiveRecord */
$isHasMany = is_array($value) && is_array(current($value));
$relName = ($isHasMany) ? lcfirst(Inflector::pluralize($key)) : lcfirst($key);

if (in_array($relName, $skippedRelations) || !array_key_exists($relName,$relData)){
continue;
}

$AQ = $this->getRelation($relName);
$relModelClass = $AQ->modelClass;
$relPKAttr = $relModelClass::primaryKey();
$isManyMany = count($relPKAttr) > 1;

if (in_array($relName, $skippedRelations) || !array_key_exists($relName,$relData))
continue;

if ($isManyMany) {
$container = [];
foreach ($value as $relPost) {
Expand Down

0 comments on commit b41ca3a

Please sign in to comment.