Skip to content

Commit

Permalink
[update] remove unnecessary check for id_field
Browse files Browse the repository at this point in the history
  • Loading branch information
georgehristov committed Jul 26, 2020
1 parent 6156ae2 commit b2c69db
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/Reference/HasMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function getOurValue()

// create expression based on existing conditions
return $ourModel->action('field', [
$this->our_field ?: ($ourModel->id_field ?: 'id'),
$this->our_field ?: $ourModel->id_field,
]);
}

Expand All @@ -44,7 +44,7 @@ protected function referenceOurValue(): Field

$ourModel->persistence_data['use_table_prefixes'] = true;

return $ourModel->getField($this->our_field ?: ($ourModel->id_field ?: 'id'));
return $ourModel->getField($this->our_field ?: $ourModel->id_field);
}

/**
Expand All @@ -57,7 +57,7 @@ public function ref($defaults = []): Model
$ourModel = $this->getOurModel();

return $this->getTheirModel($defaults)->addCondition(
$this->their_field ?: ($ourModel->table . '_' . ($ourModel->id_field ?: 'id')),
$this->their_field ?: ($ourModel->table . '_' . $ourModel->id_field),
$this->getOurValue()
);
}
Expand All @@ -72,7 +72,7 @@ public function refLink($defaults = []): Model
$ourModel = $this->getOurModel();

$theirModelLinked = $this->getTheirModel($defaults)->addCondition(
$this->their_field ?: ($ourModel->table . '_' . ($ourModel->id_field ?: 'id')),
$this->their_field ?: ($ourModel->table . '_' . $ourModel->id_field),
$this->referenceOurValue()
);

Expand Down
2 changes: 1 addition & 1 deletion src/Reference/HasOneSql.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public function addTitle($defaults = []): FieldSqlExpression

$ourModel = $this->getOurModel();

$field = $defaults['field'] ?? preg_replace('/_' . ($ourModel->id_field ?: 'id') . '$/i', '', $this->link);
$field = $defaults['field'] ?? preg_replace('/_' . $ourModel->id_field . '$/i', '', $this->link);

if ($ourModel->hasField($field)) {
throw (new Exception('Field with this name already exists. Please set title field name manually addTitle([\'field\'=>\'field_name\'])'))
Expand Down

0 comments on commit b2c69db

Please sign in to comment.