specify fares, js to dynamically change fare form; get applicable fares for the flight/pirep #125
This commit is contained in:
@@ -12,6 +12,7 @@ use App\Models\Enums\PirepSource;
|
||||
use App\Models\Enums\PirepState;
|
||||
use App\Models\Navdata;
|
||||
use App\Models\Pirep;
|
||||
use App\Models\PirepFare;
|
||||
use App\Models\PirepFieldValues;
|
||||
use App\Models\User;
|
||||
use App\Repositories\AcarsRepository;
|
||||
@@ -210,6 +211,29 @@ class PIREPService extends BaseService
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the list of fares
|
||||
* @param $pirep_id
|
||||
* @param array $fares ['field_id', 'count']
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function saveFares($pirep_id, array $fares)
|
||||
{
|
||||
if(!$fares) { return; }
|
||||
|
||||
# Remove all the previous fares
|
||||
PirepFare::where('pirep_id', $pirep_id)->delete();
|
||||
|
||||
# Add them in
|
||||
foreach($fares as $fare) {
|
||||
$fare['pirep_id'] = $pirep_id;
|
||||
# other fields: ['fare_id', 'count']
|
||||
|
||||
$field = new PirepFare($fare);
|
||||
$field->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Pirep $pirep
|
||||
* @param int $new_state
|
||||
|
||||
Reference in New Issue
Block a user