Fix issue with flight fields not adding correctly
This commit is contained in:
parent
33daaf4a35
commit
1eb7e5d59a
@ -398,21 +398,25 @@ class FlightController extends Controller
|
|||||||
if ($request->isMethod('post')) {
|
if ($request->isMethod('post')) {
|
||||||
Log::info('Adding new flight field, flight: '.$flight_id, $request->input());
|
Log::info('Adding new flight field, flight: '.$flight_id, $request->input());
|
||||||
|
|
||||||
$field = new FlightFieldValue;
|
$field = new FlightFieldValue();
|
||||||
$field->flight_id = $flight_id;
|
$field->flight_id = $flight_id;
|
||||||
$field->name = $request->input('name');
|
$field->name = $request->input('name');
|
||||||
$field->value = $request->input('value');
|
$field->value = $request->input('value');
|
||||||
$field->save();
|
$field->save();
|
||||||
} elseif ($request->isMethod('put')) {
|
} elseif ($request->isMethod('put')) {
|
||||||
Log::info('Updating flight field, flight: '.$flight_id, $request->input());
|
Log::info('Updating flight field, flight: '.$flight_id, $request->input());
|
||||||
$field = FlightFieldValue::where('name', $request->input('name'))->first();
|
$field = FlightFieldValue::where([
|
||||||
|
'name' => $request->input('name'),
|
||||||
|
'flight_id' => $flight_id,
|
||||||
|
])->first();
|
||||||
|
|
||||||
if(!$field) {
|
if(!$field) {
|
||||||
Log::info('Field not found, creating new');
|
Log::info('Field not found, creating new');
|
||||||
$field = new FlightFieldValue();
|
$field = new FlightFieldValue();
|
||||||
$field->flight_id = $flight_id;
|
|
||||||
$field->name = $request->input('name');
|
$field->name = $request->input('name');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$field->flight_id = $flight_id;
|
||||||
$field->value = $request->input('value');
|
$field->value = $request->input('value');
|
||||||
$field->save();
|
$field->save();
|
||||||
// update the field value
|
// update the field value
|
||||||
|
Loading…
Reference in New Issue
Block a user