* @date 2021/12/10 0010 */ public function getStats(Model $model, $columnField, $columnKey, $where = [], $with = '') { $map = array_merge([], $where); $array = ['total','today','month','year']; $data = []; foreach ($array as $key => $item) { $app = $model->with($with)->where($map); if ($key) { $app->whereTime('created_at', $item); } $list = $app->select(); foreach ($list as $index => $value) { if (!$value['paylog']) { unset($list[$index]); } } $data[$item] = array_column(Collection::make($list)->toArray(), $columnField, $columnKey); } return $data; } }