Skip to content

Commit

Permalink
修复grid没经过toArray时时间戳自动加上时区问题
Browse files Browse the repository at this point in the history
  • Loading branch information
lphkxd committed Oct 14, 2020
1 parent 87104ad commit 48504b1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Grid/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* @contact 4213509@qq.com
* @license https://github.com/lphkxd/hyperf-plus/blob/master/LICENSE
*/

namespace HPlus\UI\Grid;


Expand All @@ -21,6 +22,7 @@
use Hyperf\Utils\Arr;
use Hyperf\Utils\Str;
use HPlus\UI\Grid;
use Mzh\Helper\RunTimes;

/**
* Class Model
Expand Down Expand Up @@ -428,7 +430,11 @@ public function displayData($data)
data_set($item, $column->getName(), $c_value);
}
} else {
$n_value = $column->customValueUsing($row, data_get($row, $column->getName(), $column->getDefaultValue()));
$dataValue = data_get($row, $column->getName(), $column->getDefaultValue());
if ($this->sModel != null && $dataValue instanceof \Carbon\Carbon) {
$dataValue = $dataValue->format($this->sModel->getDateFormat());
}
$n_value = $column->customValueUsing($row, $dataValue);
data_set($item, $column->getName(), $n_value);
}
}
Expand Down Expand Up @@ -483,17 +489,14 @@ public function get()
$this->queries->unique()->each(function ($query) {
$this->model = call_user_func_array([$this->model, $query['method']], $query['arguments']);
});

$data = $this->model;

if ($this->model instanceof Collection) {
if ($data->count() > 0) {
return $this->displayData($data);
} else {
return $data;
}
}

if ($this->model instanceof LengthAwarePaginator) {
return [
'current_page' => $this->model->currentPage(),
Expand Down

0 comments on commit 48504b1

Please sign in to comment.