setValue('TOTAL', $vote->logs()->distinct('user_id')->count()); $templateProcessor->setValue('TITLE', $vote->title); $i = 0; $tpl = ''; foreach ($vote->items as $item) { $i++; $tpl .= $i . '. ' . $item->name . ' ' . $item->logs()->sum('result') . " 票\r"; } $templateProcessor->setValue('TPL', $tpl); $save = 'chae_1.docx'; $templateProcessor->saveAs(storage_path('app/public/' . $save)); return $this->response()->success('倒出成功')->download('/storage/' . $save); } public function html(): string { return << 差额数据倒出 HTML; } }