public function getTexts(Guard $auth, $taskId) { $task = Task::findOrFail($taskId); $texts = TextCrawl::where('task_id', $taskId)->take($task->max_document)->get(); $title = "crawl/" . $task->id . "_" . \Carbon\Carbon::now()->format('Y-m-d-His') . "_texts.txt"; foreach ($texts as $text) { file_put_contents($title, $text->text . "\n", FILE_APPEND); } return response()->download($title)->deleteFileAfterSend(true); }