Add ability to export members of a subfleet only (#1471)

* Export Subfleet Members

* Style Fix

* Fix php-cs style complaints

* Disable php-cs-fixer and fix styles
This commit is contained in:
B.Fatih KOZ
2022-08-15 17:45:10 +03:00
committed by GitHub
parent 6becc6de63
commit ccebc69be2
3 changed files with 37 additions and 13 deletions

View File

@@ -212,14 +212,19 @@ class AircraftController extends Controller
public function export(Request $request)
{
$exporter = app(ExportService::class);
$aircraft = $this->aircraftRepo->all();
$where = [];
$file_name = 'aircraft.csv';
if ($request->input('subfleet')) {
$subfleet_id = $request->input('subfleet');
$where['subfleet_id'] = $subfleet_id;
$file_name = 'aircraft-'.$subfleet_id.'.csv';
}
$aircraft = $this->aircraftRepo->where($where)->orderBy('registration')->get();
$path = $exporter->exportAircraft($aircraft);
return response()
->download($path, 'aircraft.csv', [
'content-type' => 'text/csv',
])
->deleteFileAfterSend(true);
return response()->download($path, $file_name, ['content-type' => 'text/csv'])->deleteFileAfterSend(true);
}
/**