/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $rules = array('name' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     // process the login
     if ($validator->fails()) {
         return Redirect::to('teams/create')->withErrors($validator);
     } else {
         // store
         $team = new Team();
         $team->name = Input::get('name');
         $team->description = Input::get('description');
         $team->user_id = Auth::user()->id;
         $team->save();
         $team->projects()->attach($request->input('project_list'));
         // redirect
         Session::flash('message', 'Successfully created team!');
         return Redirect::to('user/teams');
     }
 }