/**
  * Show the form for creating a new resource.
  * GET /credentials/create
  *
  * @return Response
  */
 public function create()
 {
     $rules = array('name' => 'required', 'username' => 'required', 'password' => 'required', 'type' => 'required');
     $validator = Validator::make($data = Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $credential = new Credential();
     $credential->user_id = Auth::id();
     $credential->project_id = Input::get('project_id');
     $credential->name = Input::get('name');
     $credential->username = Input::get('username');
     $credential->password = Input::get('password');
     if (Input::get('type') == "server") {
         $credential->type = true;
         $credential->hostname = Input::get('hostname');
         $credential->port = Input::get('port');
     } else {
         $credential->type = false;
         $credential->hostname = "";
         $credential->port = "";
     }
     $credential->save();
     return Redirect::back();
 }