assetType.'.csv'; // Create the directory - makes it inside of storage/app Storage::makeDirectory('import'); $path = storage_path('/app/import/export_'.$filename.'.csv'); Log::info('Exporting "'.$exporter->assetType.'" to '.$path); $writer = $this->openCsv($path); // Write out the header first $writer->insertOne($exporter->getColumns()); // Write the rest of the rows foreach ($collection as $row) { $writer->insertOne($exporter->export($row)); } return $path; } /** * Export all of the aircraft * * @param Collection $aircraft * * @throws \League\Csv\CannotInsertRecord * * @return mixed */ public function exportAircraft($aircraft) { return $this->runExport($aircraft, new AircraftExporter()); } /** * Export all of the airports * * @param Collection $airports * * @throws \League\Csv\CannotInsertRecord * * @return mixed */ public function exportAirports($airports) { return $this->runExport($airports, new AirportExporter()); } /** * Export all of the airports * * @param Collection $expenses * * @throws \League\Csv\CannotInsertRecord * * @return mixed */ public function exportExpenses($expenses) { return $this->runExport($expenses, new ExpenseExporter()); } /** * Export all of the fares * * @param Collection $fares * * @throws \League\Csv\CannotInsertRecord * * @return mixed */ public function exportFares($fares) { return $this->runExport($fares, new FareExporter()); } /** * Export all of the flights * * @param Collection $flights * * @throws \League\Csv\CannotInsertRecord * * @return mixed */ public function exportFlights($flights) { return $this->runExport($flights, new FlightExporter()); } /** * Export all of the flights * * @param Collection $subfleets * * @throws \League\Csv\CannotInsertRecord * * @return mixed */ public function exportSubfleets($subfleets) { return $this->runExport($subfleets, new SubfleetExporter()); } }