Skip to content

Commit

Permalink
Merge pull request #1942 from ridaamirini/8.0
Browse files Browse the repository at this point in the history
[8.0] Keep casted attributes #1747
  • Loading branch information
yajra authored Jan 4, 2019
2 parents 4e9a1d2 + 83138f3 commit cfd0599
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/Processors/DataProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,11 @@ protected function escapeColumns(array $output)
} elseif (is_array($this->escapeColumns)) {
$columns = array_diff($this->escapeColumns, $this->rawColumns);
foreach ($columns as $key) {
array_set($row, $key, e(array_get($row, $key)));
$data = array_get($row, $key);
$dataType = gettype($data);
$data = e($data);
settype($data, $dataType);
array_set($row, $key, $data);
}
}

Expand All @@ -251,7 +255,9 @@ protected function escapeRow(array $row)
$arrayDot = array_filter(array_dot($row));
foreach ($arrayDot as $key => $value) {
if (! in_array($key, $this->rawColumns)) {
$dataType = gettype($value);
$arrayDot[$key] = e($value);
settype($arrayDot[$key], $dataType);
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/Utilities/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ public static function getOrMethod($method)
*/
public static function convertToArray($row)
{
$data = $row instanceof Arrayable ? $row->toArray() : (array) $row;
$data = $row instanceof Arrayable ?
$row->toArray() :
($row instanceof \StdClass ? (array) $row : $row);

foreach ($data as &$value) {
if (is_object($value) || is_array($value)) {
Expand Down

0 comments on commit cfd0599

Please sign in to comment.