Add ability to export flights of an airline only(#1375)
* Airline Flight Export Add ability to export flights of an airline only * StyleFix
This commit is contained in:
parent
7799867302
commit
d3b7d25abd
@ -300,14 +300,18 @@ class FlightController extends Controller
|
||||
public function export(Request $request)
|
||||
{
|
||||
$exporter = app(ExportService::class);
|
||||
$flights = $this->flightRepo->all();
|
||||
|
||||
$where = [];
|
||||
$file_name = 'flights.csv';
|
||||
if ($request->input('airline_id')) {
|
||||
$airline_id = $request->input('airline_id');
|
||||
$where['airline_id'] = $airline_id;
|
||||
$file_name = 'flights-'.$airline_id.'.csv';
|
||||
}
|
||||
$flights = $this->flightRepo->where($where)->get();
|
||||
|
||||
$path = $exporter->exportFlights($flights);
|
||||
return response()
|
||||
->download($path, 'flights.csv', [
|
||||
'content-type' => 'text/csv',
|
||||
])
|
||||
->deleteFileAfterSend(true);
|
||||
return response()->download($path, $file_name, ['content-type' => 'text/csv'])->deleteFileAfterSend(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,8 +2,15 @@
|
||||
@section('title', 'Flights')
|
||||
|
||||
@section('actions')
|
||||
<li><a href="{{ route('admin.flights.export') }}"><i class="ti-plus"></i>Export to CSV</a></li>
|
||||
<li><a href="{{ route('admin.flights.import') }}"><i class="ti-plus"></i>Import from CSV</a></li>
|
||||
<li>
|
||||
<a href="{{ route('admin.flights.export') }}@if(request()->get('airline_id')){{ '?airline_id='.request()->get('airline_id') }}@endif">
|
||||
<i class="ti-plus"></i>
|
||||
Export to CSV @if(request()->get('airline_id')) (Selected Airline) @endif
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ route('admin.flights.import') }}"><i class="ti-plus"></i>Import from CSV</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ route('admin.flights.create') }}">
|
||||
<i class="ti-plus"></i>
|
||||
|
Loading…
Reference in New Issue
Block a user