where($batch_where)->order('id DESC') ->page((int)$where['page'], (int)$where['limit']) ->select() ->each(function ($item) { $item['add_time'] = ($item['add_time'] != 0 || $item['add_time']) ? date('Y-m-d H:i:s', $item['add_time']) : ''; $item['special_title'] = Special::where('id', $item['special_id'])->value('title'); }); $data = count((array)$data) ? $data->toArray() : []; $count = self::where($batch_where)->count(); return compact('data', 'count'); } public function getCreateTimeAttr($time) { return $time;//返回create_time原始数据,不进行时间戳转换。 } public static function getBatchAll(array $where) { if (!$where || !is_array($where)) { $where = array(); } return self::where($where)->select(); } public static function delSpecialBatch($id) { $res = self::where('id', $id)->delete(); $res1 = false; if ($res) { $res1 = SpecialExchange::where('card_batch_id', $id)->delete(); } $res2 = $res && $res1; return $res2; } }