Skip to content

Commit

Permalink
Bugfixes with recursive getDirty
Browse files Browse the repository at this point in the history
  • Loading branch information
dmongeau committed Mar 11, 2018
1 parent 16ca46f commit de67577
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/Folklore/EloquentJsonSchema/Support/HasJsonSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -508,4 +508,23 @@ public function isSavingJsonSchemas()
{
return $this->savingJsonSchemas;
}

/**
* Get dirty json schemas attributes
*
* @return boolean
*/
public function getDirtyJsonSchemas()
{
$dirty = [];

foreach ($this->getJsonSchemaAttributes() as $key) {
$value = array_get($this->attributes, $key);
if ($value !== $this->getOriginal($key)) {
$dirty[$key] = $value;
}
}

return $dirty;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected function shouldQueryRelation($model, $node, $state, $value)
$model->isSavingJsonSchemas() ||
$relationClass instanceof HasOneOrMany ||
!$model->exists ||
sizeof($model->getDirty())
sizeof($model->getDirtyJsonSchemas())
);
}

Expand Down

0 comments on commit de67577

Please sign in to comment.