File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
src/Database/Eloquent/Relations Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -147,9 +147,20 @@ protected function parseId($value)
147147 }
148148
149149 if ($ this ->related ->hasMutator ($ this ->related ->getKeyName ())) {
150+ // Check if already serialized (cache check)
151+ if (in_array ($ value , $ this ->mutated_values ) === true ) {
152+ return $ value ;
153+ }
154+ // Check if value is already binary (not a valid UUID string)
155+ // If it's not printable/is binary, assume it's already serialized
156+ if (!ctype_print ($ value )) {
157+ return $ value ;
158+ }
150159 $ related = $ this ->related ;
151-
152- return $ related ->serializeAttribute ($ related ->getKeyName (), $ value );
160+ $ serialized = $ related ->serializeAttribute ($ related ->getKeyName (), $ value );
161+ // Add to cache
162+ $ this ->mutated_values [] = $ serialized ;
163+ return $ serialized ;
153164 }
154165
155166 return $ value ;
@@ -184,6 +195,10 @@ protected function parseIds($value)
184195 return $ attribute ;
185196 }
186197
198+ if (!ctype_print ($ attribute )) {
199+ return $ attribute ; // Already binary, skip serialization
200+ }
201+
187202 $ value = $ related ->serializeAttribute ($ related ->getKeyName (), $ attribute );
188203 $ this ->mutated_values [] = $ value ;
189204
You can’t perform that action at this time.
0 commit comments