@@ -18,7 +18,7 @@ class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo
18
18
*/
19
19
public function getHasCompareKey ()
20
20
{
21
- return $ this ->getOwnerKey () ;
21
+ return $ this ->ownerKey ;
22
22
}
23
23
24
24
/** @inheritdoc */
@@ -28,7 +28,7 @@ public function addConstraints()
28
28
// For belongs to relationships, which are essentially the inverse of has one
29
29
// or has many relationships, we need to actually query on the primary key
30
30
// 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 });
32
32
}
33
33
}
34
34
@@ -38,9 +38,7 @@ public function addEagerConstraints(array $models)
38
38
// We'll grab the primary key name of the related models since it could be set to
39
39
// a non-standard name and not "id". We will then construct the constraint for
40
40
// 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 ));
44
42
}
45
43
46
44
/** @inheritdoc */
@@ -49,16 +47,6 @@ public function getRelationExistenceQuery(Builder $query, Builder $parentQuery,
49
47
return $ query ;
50
48
}
51
49
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
-
62
50
/**
63
51
* Get the name of the "where in" method for eager loading.
64
52
*
0 commit comments