Example #1
0
 public function getIndex(Request $request)
 {
     User::createTable();
     // User::createAdmin('*****@*****.**','admin');
     Img::createTable();
     Mylog::createTable();
     Email::createTable();
     Banner::createTable();
     Activity::createTable();
     Form::createTable();
     Field::createTable();
     FieldChildren::createTable();
     Result::createTable();
     ResultRow::createTable();
     Charge::createTable();
 }
Example #2
0
 public function postFSave(FSavePRequest $request, $user_email, $form_url)
 {
     $user = User::where('user_email', base64_decode($user_email))->where('user_active', '1')->firstOrFail();
     $form = $user->Form()->where('form_url', $form_url)->where('form_active', 1)->firstOrFail();
     if (!$form->canWrite()) {
         return redirect()->back()->with('msgError', '表单已经超过填写人数的最大限制了');
     }
     $agent = new Agent();
     $platform = $agent->platform();
     $platform_v = $agent->version($platform);
     $browser = $agent->browser();
     $browser_v = $agent->version($browser);
     $device = $agent->device();
     $result = Result::create(['result_ruid' => Auth::check() ? Auth::id() : 0, 'result_form_id' => $form->form_id, 'result_ip' => ip2long($request->ip()), 'result_device' => $device, 'result_system' => $platform, 'result_system_v' => $platform_v, 'result_browser' => $browser, 'result_browser_v' => $browser_v]);
     if ($result) {
         //插入数据
         $fields = $form->Field()->orderBy('field_sort', 'ASC')->get();
         $splitStr = ':$split$:';
         $user_id = Auth::check() ? Auth::id() : 0;
         foreach ($fields as $field) {
             $inputs = $request->input($field->field_attr_name);
             if (is_array($inputs)) {
                 if ($field->field_type == 'group:shop-thumbnail') {
                     $rows = [];
                     foreach ($inputs as $input) {
                         $rows[] = $input['goods_name'] . '(' . $input['goods_preice'] . '):' . $input['goods_num'];
                     }
                     $resultrow_attr_value = implode($splitStr, $rows);
                 } else {
                     $resultrow_attr_value = implode($splitStr, $inputs);
                 }
             } else {
                 $resultrow_attr_value = $inputs;
             }
             ResultRow::create(['resultrow_ruid' => $user_id, 'resultrow_result_id' => $result->result_id, 'resultrow_sort' => $field->field_sort, 'resultrow_type' => $field->field_type, 'resultrow_title' => $field->field_title, 'resultrow_tips' => $field->field_tips, 'resultrow_attr_name' => $field->field_attr_name, 'resultrow_attr_value' => $resultrow_attr_value]);
         }
         // 发送邮件提示
         if ($form->form_tips_email) {
             $email = Email::create(['email_cuid' => 0, 'email_ruid' => $user->user_id, 'email_block' => 'form_reply_tips', 'email_target' => $user->user_email, 'email_title' => '[ ' . WEBSITE_NAME . ' ]提示您:您的表单有了新的回复', 'email_datas' => $form->form_code, 'email_is_sent' => 0]);
             $this->dispatch(new SendReminderEmail($email));
         }
         $res = redirect('/u/' . $user_email . '/f-success')->with('msgSuccess', '您的表单已经成功提交,感谢您的参与。');
     } else {
         $res = redirect()->back()->with('msgError', MSG_FA);
     }
     return $res;
 }