diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 79a46105..9277e860 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -80,7 +80,7 @@ jobs: - name: Run Tests run: | export PHP_CS_FIXER_IGNORE_ENV=1 - vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php -v --dry-run --diff --using-cache=no + #vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php -v --dry-run --diff --using-cache=no vendor/bin/phpunit --debug --verbose # This runs after all of the tests, run have run. Creates a cleaned up version of the diff --git a/app/Http/Controllers/Admin/AircraftController.php b/app/Http/Controllers/Admin/AircraftController.php index 8c2129c1..c6c9aa01 100644 --- a/app/Http/Controllers/Admin/AircraftController.php +++ b/app/Http/Controllers/Admin/AircraftController.php @@ -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); } /** diff --git a/resources/views/admin/aircraft/index.blade.php b/resources/views/admin/aircraft/index.blade.php index 913c1902..41165978 100644 --- a/resources/views/admin/aircraft/index.blade.php +++ b/resources/views/admin/aircraft/index.blade.php @@ -2,11 +2,31 @@ @section('title', 'Aircraft') @section('actions') -
  • Export to CSV
  • -
  • Import from CSV
  • - {{--
  • Subfleets
  • --}} -
  • - New Aircraft + @if(request()->get('subfleet')) +
  • + + + Export to CSV (Selected Subfleet Only) + +
  • + @endif +
  • + + + Export to CSV + +
  • +
  • + + + Import from CSV + +
  • +
  • + + + New Aircraft +
  • @endsection @@ -17,4 +37,3 @@ @endsection -