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) { $exporter = new AircraftExporter(); return $this->runExport($aircraft, $exporter); } /** * Export all of the airports * * @param Collection $airports * * @throws \League\Csv\CannotInsertRecord * * @return mixed */ public function exportAirports($airports) { $exporter = new AirportExporter(); return $this->runExport($airports, $exporter); } /** * Export all of the airports * * @param Collection $expenses * * @throws \League\Csv\CannotInsertRecord * * @return mixed */ public function exportExpenses($expenses) { $exporter = new ExpenseExporter(); return $this->runExport($expenses, $exporter); } /** * Export all of the fares * * @param Collection $fares * * @throws \League\Csv\CannotInsertRecord * * @return mixed */ public function exportFares($fares) { $exporter = new FareExporter(); return $this->runExport($fares, $exporter); } /** * Export all of the flights * * @param Collection $flights * * @throws \League\Csv\CannotInsertRecord * * @return mixed */ public function exportFlights($flights) { $exporter = new FlightExporter(); return $this->runExport($flights, $exporter); } /** * Export all of the flights * * @param Collection $subfleets * * @throws \League\Csv\CannotInsertRecord * * @return mixed */ public function exportSubfleets($subfleets) { $exporter = new SubfleetExporter(); return $this->runExport($subfleets, $exporter); } }