/** * Update field options * @param Field $field * @return Field with updated Options */ public function updateFieldOptions(Field $field, $field_options) { foreach ($field_options as $key => $value) { $option = FieldOption::findOrNew($key); $option->text = $value; $option->name = strtolower(str_replace(' ', '_', $value)); $option->field_id = $field->id; $option->save(); } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $fieldOption = FieldOption::findOrFail($id); $fieldOption->delete(); return response()->json(['status' => 'success']); }