/**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     try {
         $input = \Input::all();
         $input['show_captcha'] = isset($input['show_captcha']);
         $validator = \BuiltForm::validate($input, $id);
         if ($validator->passes()) {
             $form = \BuiltForm::findOrFail($id);
             $form->name = $input['name'];
             if ($form->hash == '') {
                 $form->hash = uniqid('form_');
             }
             $form->category = $input['category'];
             $form->show_captcha = $input['show_captcha'];
             $form->description = $input['description'];
             $form->data = $input['data'];
             $form->redirect_to = $input['redirect_to'];
             $form->extra_code = base64_decode($input['extra_code']);
             $form->email = $input['email'];
             $form->rendered = base64_decode($input['rendered']);
             if ($form->save()) {
                 return \Redirect::to('backend/form-builder')->with('success_message', 'Form was updated.');
             } else {
                 return \Redirect::to('backend/form-builder')->with('error_message', 'Form wasn\'t updated.');
             }
         } else {
             // Form validation failed
             return \Redirect::back()->withInput()->withErrors($validator);
         }
     } catch (\Exception $e) {
         dd($e->getMessage());
         return \Redirect::back()->with('error_message', 'The form wasn\'t updated.');
     }
 }