Skip to content

Commit

Permalink
Fixed a bug in camel casing where relationships were being missed.
Browse files Browse the repository at this point in the history
  • Loading branch information
kirkbushell committed Apr 22, 2024
1 parent 2017747 commit 149924a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Behaviours/HasCamelCasing.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public function setAttribute($key, $value)
* @param string $key
* @return mixed
*/
public function getAttribute($key)
public function getAttribute($key): mixed
{
return parent::getAttribute($this->getSnakeKey($key));
return $this->isRelation($key) ? parent::getAttribute($key) : parent::getAttribute($this->getSnakeKey($key));
}

/**
Expand Down Expand Up @@ -195,4 +195,4 @@ public function __unset($key)
{
return parent::__unset($this->getSnakeKey($key));
}
}
}
7 changes: 6 additions & 1 deletion tests/Unit/Stubs/ParentModelStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@ public function setAttribute($key, $value)
{
$this->attributes[$key] = $value;
}
}

public function isRelation($key)
{
return false;
}
}

0 comments on commit 149924a

Please sign in to comment.