Skip to content

Commit 4c46262

Browse files
authored
Merge pull request #368 from bowphp/refactor/code-base
Fix belongs to
2 parents cebeecb + 86a94de commit 4c46262

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Database/Barry/Relations/BelongsTo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(
3838
*/
3939
public function getResults(): mixed
4040
{
41-
$key = $this->query->getTable() . ":belongsto:" . $this->related->getTable() . ":" . $this->foreign_key;
41+
$key = $this->query->getTable() . ":" . $this->local_key . ":belongsto:" . $this->related->getTable() . ":" . $this->foreign_key;
4242

4343
$cache = Cache::store('file')->get($key);
4444

src/Database/Barry/Relations/HasOne.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(Model $related, Model $parent, string $foreign_key,
3333
*/
3434
public function getResults(): ?Model
3535
{
36-
$key = $this->query->getTable() . ":hasone:" . $this->related->getTable() . ":" . $this->foreign_key;
36+
$key = $this->query->getTable() . ":" . $this->local_key . ":hasone:" . $this->related->getTable() . ":" . $this->foreign_key;
3737

3838
$cache = Cache::store('file')->get($key);
3939

0 commit comments

Comments
 (0)