From 584b988093d0f0ef2e914d7cf0453335b6a5f527 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sat, 5 Nov 2022 15:17:00 +1100 Subject: [PATCH] UTF8 decoding needs to be done after casting --- app/Traits/EncodeUTF8.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Traits/EncodeUTF8.php b/app/Traits/EncodeUTF8.php index 2b83413..5881e4c 100644 --- a/app/Traits/EncodeUTF8.php +++ b/app/Traits/EncodeUTF8.php @@ -82,8 +82,11 @@ trait EncodeUTF8 public function getAttribute($key) { if (in_array($key,self::cast_utf8) && Arr::get($this->attributes,$key) && (! Arr::get($this->_encoded,$key))) { - $this->attributes[$key] = utf8_decode($this->attributes[$key]); + // We need to get it from the parent first, taking into account any casting + $this->attributes[$key] = utf8_decode(parent::getAttribute($key)); $this->_encoded[$key] = TRUE; + + return $this->attributes[$key]; } return parent::getAttribute($key);