Esempio n. 1
0
 /**
  * Store a newly created resource in storage.
  * @return Response
  */
 public function store()
 {
     try {
         $input = \Input::all();
         $input['show_captcha'] = isset($input['show_captcha']);
         $validator = \BuiltForm::validate($input);
         if ($validator->passes()) {
             $form = \BuiltForm::create(array('name' => $input['name'], 'hash' => uniqid('form_'), 'category' => $input['category'], 'description' => $input['description'], 'show_captcha' => $input['show_captcha'], 'data' => $input['data'], 'redirect_to' => $input['redirect_to'], 'extra_code' => base64_decode($input['extra_code']), 'email' => $input['email'], 'rendered' => base64_decode($input['rendered'])));
             if ($form) {
                 return \Redirect::to('backend/form-builder')->with('success_message', 'The form was created.');
             } else {
                 return \Redirect::to('backend/form-builder')->with('error_message', 'The form was\'t created.');
             }
         } else {
             // Form validation failed
             return \Redirect::back()->withInput()->withErrors($validator);
         }
     } catch (\Exception $e) {
         return \Redirect::back()->with('error_message', 'The form wasn\'t created.');
     }
 }