'datetime:Y-m-d H:i:s', // 指定序列化格式 'created_at' => 'datetime:Y-m-d H:i:s', // 指定序列化格式 // 'updated_at' => 'timestamp', // 指定序列化格式 // 'created_at' => 'timestamp', // 指定序列化格式 ]; /** * 重新格式化时间 * @param DateTimeInterface $date * @return string */ protected function serializeDate(DateTimeInterface $date): string { return $date->format(Carbon::parse($date)->toDateTimeString()); } public static function getCustomer($customer) { $customer['grade_txt'] = Constants::GRADE[$customer['grade']]; $customer['magnitude_txt'] = Constants::MAGNITUDE[$customer['magnitude']]; $customer['sex_txt'] = Constants::SEX[$customer['sex']]; if ($customer['grade']<=2) { $customer['follow'] = 0; $customer['follow_txt'] = '跟进中'; }elseif ($customer['grade']<=5) { $customer['follow'] = 1; $customer['follow_txt'] = '已成交'; }else{ $customer['follow'] = 2; $customer['follow_txt'] = '已流失'; } $where = [ 'customer_id' => $customer['id'] ]; $begin_follow = Follow::select('id','created_at','updated_at') ->where($where) ->min('created_at'); $customer['begin_follow'] = Util::timeTotDate($begin_follow); // $customer['created_at'] = Util::timeTotDate($customer['created_at']); // $customer['updated_at'] = Util::timeTotDate($customer['updated_at']); $customer = Util::formatDate($customer,['follow_last']); $customer['car_type_name'] = empty($customer['car_type_id'])?'':CarType::where(['id'=>$customer['car_type_id']])->value('name'); $customer['country_name'] = empty($customer['country_id'])?'':Country::where(['id'=>$customer['country_id']])->value('cn_addr'); // $customer['last_follow'] = $last_follow; return $customer; } }