Add days of week to flights table; add to import/export for flights

This commit is contained in:
Nabeel Shahzad
2018-03-22 21:21:35 -05:00
parent 8b53ca2fdc
commit 7105e82922
17 changed files with 310 additions and 21 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Services\ImportExport;
use App\Interfaces\ImportExport;
use App\Models\Enums\Days;
use App\Models\Enums\FlightType;
use App\Models\Flight;
@@ -39,6 +40,7 @@ class FlightExporter extends ImportExport
$ret['airline'] = $ret['airline']->icao;
$ret['distance'] = $ret['distance']->toNumber();
$ret['days'] = $this->getDays($flight);
$ret['flight_type'] = FlightType::convertToCode($ret['flight_type']);
$ret['fares'] = $this->getFares($flight);
@@ -48,6 +50,46 @@ class FlightExporter extends ImportExport
return $ret;
}
/**
* Return the days string
* @param Flight $flight
* @return string
*/
protected function getDays(Flight &$flight)
{
$days_str = '';
if($flight->on_day(Days::MONDAY)) {
$days_str .= '1';
}
if ($flight->on_day(Days::TUESDAY)) {
$days_str .= '2';
}
if ($flight->on_day(Days::WEDNESDAY)) {
$days_str .= '3';
}
if ($flight->on_day(Days::THURSDAY)) {
$days_str .= '4';
}
if ($flight->on_day(Days::FRIDAY)) {
$days_str .= '5';
}
if ($flight->on_day(Days::SATURDAY)) {
$days_str .= '6';
}
if ($flight->on_day(Days::SUNDAY)) {
$days_str .= '7';
}
return $days_str;
}
/**
* Return any custom fares that have been made to this flight
* @param Flight $flight