/**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Forms $forms)
 {
     if (!Input::get('formname')) {
         return Redirect::back()->with('fails', 'Please fill Form name');
     }
     $required = Input::get('required');
     $count = count($required);
     $require = array();
     for ($i = 2; $i < $count + 2; $i++) {
         for ($j = 0; $j < 1; $j++) {
             array_push($require, $required[$i][$j]);
         }
     }
     $forms->formname = Input::get('formname');
     $forms->save();
     $count = count(Input::get('name'));
     $fields = array();
     for ($i = 0; $i <= $count; $i++) {
         if (!empty(Input::get('name')[$i])) {
             array_push($fields, array('forms_id' => $forms->id, 'label' => Input::get('label')[$i], 'name' => Input::get('name')[$i], 'type' => Input::get('type')[$i], 'value' => Input::get('value')[$i], 'required' => $require[$i]));
         }
     }
     Fields::insert($fields);
     return Redirect::back()->with('success', 'Successfully created Form');
 }
 /**
  * Show the form for editing the specified resource.
  * @param type $id
  * @param type Priority $priority
  * @param type Department $department
  * @param type Help_topic $topic
  * @param type Form_name $form
  * @param type Agents $agent
  * @param type Sla_plan $sla
  * @return type Response
  */
 public function edit($id, Ticket_Priority $priority, Department $department, Help_topic $topic, Forms $form, Sla_plan $sla)
 {
     try {
         $agents = User::where('role', '=', 'agent')->get();
         $departments = $department->get();
         $topics = $topic->whereId($id)->first();
         $forms = $form->get();
         $slas = $sla->get();
         $priority = $priority->get();
         return view('themes.default1.admin.helpdesk.manage.helptopic.edit', compact('priority', 'departments', 'topics', 'forms', 'agents', 'slas'));
     } catch (Exception $e) {
         return view('404');
     }
 }