Skip to content

Commit eba001a

Browse files
committed
Remove cross-version patch for other/owner key
#1116
1 parent 09528a6 commit eba001a

File tree

2 files changed

+4
-26
lines changed

2 files changed

+4
-26
lines changed

src/Relations/BelongsTo.php

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo
1818
*/
1919
public function getHasCompareKey()
2020
{
21-
return $this->getOwnerKey();
21+
return $this->ownerKey;
2222
}
2323

2424
/** @inheritdoc */
@@ -28,7 +28,7 @@ public function addConstraints()
2828
// For belongs to relationships, which are essentially the inverse of has one
2929
// or has many relationships, we need to actually query on the primary key
3030
// of the related models matching on the foreign key that's on a parent.
31-
$this->query->where($this->getOwnerKey(), '=', $this->parent->{$this->foreignKey});
31+
$this->query->where($this->ownerKey, '=', $this->parent->{$this->foreignKey});
3232
}
3333
}
3434

@@ -38,9 +38,7 @@ public function addEagerConstraints(array $models)
3838
// We'll grab the primary key name of the related models since it could be set to
3939
// a non-standard name and not "id". We will then construct the constraint for
4040
// our eagerly loading query so it returns the proper models from execution.
41-
$key = $this->getOwnerKey();
42-
43-
$this->query->whereIn($key, $this->getEagerModelKeys($models));
41+
$this->query->whereIn($this->ownerKey, $this->getEagerModelKeys($models));
4442
}
4543

4644
/** @inheritdoc */
@@ -49,16 +47,6 @@ public function getRelationExistenceQuery(Builder $query, Builder $parentQuery,
4947
return $query;
5048
}
5149

52-
/**
53-
* Get the owner key with backwards compatible support.
54-
*
55-
* @return string
56-
*/
57-
public function getOwnerKey()
58-
{
59-
return property_exists($this, 'ownerKey') ? $this->ownerKey : $this->otherKey;
60-
}
61-
6250
/**
6351
* Get the name of the "where in" method for eager loading.
6452
*

src/Relations/MorphTo.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function addConstraints()
1818
// For belongs to relationships, which are essentially the inverse of has one
1919
// or has many relationships, we need to actually query on the primary key
2020
// of the related models matching on the foreign key that's on a parent.
21-
$this->query->where($this->getOwnerKey(), '=', $this->parent->{$this->foreignKey});
21+
$this->query->where($this->ownerKey, '=', $this->parent->{$this->foreignKey});
2222
}
2323
}
2424

@@ -34,16 +34,6 @@ protected function getResultsByType($type)
3434
return $query->whereIn($key, $this->gatherKeysByType($type, $instance->getKeyType()))->get();
3535
}
3636

37-
/**
38-
* Get the owner key with backwards compatible support.
39-
*
40-
* @return string
41-
*/
42-
public function getOwnerKey()
43-
{
44-
return property_exists($this, 'ownerKey') ? $this->ownerKey : $this->otherKey;
45-
}
46-
4737
/**
4838
* Get the name of the "where in" method for eager loading.
4939
*

0 commit comments

Comments
 (0)