Skip to content

Commit cfd0599

Browse files
authored
Merge pull request yajra#1942 from ridaamirini/8.0
[8.0] Keep casted attributes yajra#1747
2 parents 4e9a1d2 + 83138f3 commit cfd0599

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Processors/DataProcessor.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,11 @@ protected function escapeColumns(array $output)
232232
} elseif (is_array($this->escapeColumns)) {
233233
$columns = array_diff($this->escapeColumns, $this->rawColumns);
234234
foreach ($columns as $key) {
235-
array_set($row, $key, e(array_get($row, $key)));
235+
$data = array_get($row, $key);
236+
$dataType = gettype($data);
237+
$data = e($data);
238+
settype($data, $dataType);
239+
array_set($row, $key, $data);
236240
}
237241
}
238242

@@ -251,7 +255,9 @@ protected function escapeRow(array $row)
251255
$arrayDot = array_filter(array_dot($row));
252256
foreach ($arrayDot as $key => $value) {
253257
if (! in_array($key, $this->rawColumns)) {
258+
$dataType = gettype($value);
254259
$arrayDot[$key] = e($value);
260+
settype($arrayDot[$key], $dataType);
255261
}
256262
}
257263

src/Utilities/Helper.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ public static function getOrMethod($method)
155155
*/
156156
public static function convertToArray($row)
157157
{
158-
$data = $row instanceof Arrayable ? $row->toArray() : (array) $row;
158+
$data = $row instanceof Arrayable ?
159+
$row->toArray() :
160+
($row instanceof \StdClass ? (array) $row : $row);
159161

160162
foreach ($data as &$value) {
161163
if (is_object($value) || is_array($value)) {

0 commit comments

Comments
 (0)