public static function create(array $attributes = array()) { // dd($attributes); static::isValid($attributes); if (isset($attributes['captcha'])) { // Do not save the value of captcha to database unset($attributes['captcha']); } unset($attributes['_token']); $entry['form_id'] = $attributes['form_id']; unset($attributes['form_id']); $form = BuiltForm::findOrFail($entry['form_id']); $module_builder = new Services\ModuleBuilder(); $form_fields = $module_builder->getFormFields($form->data); $fields = array_combine($form_fields['fields'], $form_fields['field_names']); $entry['data'] = json_encode($attributes); $entry['fields'] = json_encode($fields); // dd($entry); return parent::create($entry); }
private function formatInputForEmail($input, $form_data) { $module_builder = new Services\ModuleBuilder(); $form_fields = $module_builder->getFormFields($form_data); $fields = array_combine($form_fields['fields'], $form_fields['field_names']); foreach ($fields as $key => $value) { // dd($key); $input[$value] = $input[$key]; unset($input[$key]); } unset($input['_token']); unset($input['form_id']); if (isset($input['captcha'])) { // Do not save the value of captcha to database unset($input['captcha']); } return $input; }