Skip to content

Commit

Permalink
Added extra query condition to account for values equal to 0. Removed…
Browse files Browse the repository at this point in the history
… unused variable. Added extra query parameters
  • Loading branch information
StephenMakrogianni committed Feb 18, 2019
1 parent 89569f8 commit d488361
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Extensions/ElementalAreasExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,14 @@ public function requireDefaultRecords()
}

$ownerClass = get_class($this->owner);
$tableName = $this->owner->getSchema()->tableName($ownerClass);
$elementalAreas = $this->owner->getElementalRelations();
$schema = $this->owner->getSchema();

// There is no inbuilt filter for null values
$where = [];
foreach ($elementalAreas as $areaName) {
$where[] = $schema->sqlColumnForField($ownerClass, $areaName . 'ID') . ' IS NULL';
$queryDetails = $schema->sqlColumnForField($ownerClass, $areaName . 'ID');
$where[] = $queryDetails . ' IS NULL OR ' . $queryDetails . ' = 0' ;
}

foreach ($ownerClass::get()->where(implode(' OR ', $where)) as $elementalObject) {
Expand Down

0 comments on commit d488361

Please sign in to comment.