start_date = $start_date; $this->end_date = $end_date; } public function collection() { $start_date = $this->start_date; $end_date = $this->end_date; Log::info($start_date.'---'.$end_date); $users = User::with("profileCourtship")->where("type", "<>", "marriage")->whereBetween('last_visit', [$start_date, $end_date])->get(); $rows = [ ["ID", "姓名", "昵称", "联系电话", "是否有过消费", "常住地"] ]; foreach ($users as $user) { $has_order = Order::where("user_id", $user->id)->where("pay_status", "<>", "UNPAID")->count()?"有":"无"; $province = $user->profileCourtship?$user->profileCourtship->province:""; $city = $user->profileCourtship?$user->profileCourtship->city:""; $rows[] = [$user->id, $user->name, $user->nickname, $user->mobile, $has_order, $province, $city]; } return collect($rows); } /** * @return string */ public function title(): string { return '小程序用户'; } }