/**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $rules = ['slot' => 'Integer', 'memory' => 'Integer|Min:128|Max:10240', 'status' => 'Required', 'ip' => 'Required', 'port' => 'Integer|Min:1024|Max:65534|Required', 'displayName' => '', 'user' => 'Required|Exists:users,id'];
     $v = Validator::make(Input::all(), $rules);
     if ($v->passes()) {
         $ip_port = new GameserverIp();
         $ip_port->port = Input::get('port');
         $ip = Ip::find(Input::get('ip'));
         $ip_port->ip()->associate($ip);
         $ip_port->save();
         $user = User::find(Input::get('user'));
         $game = Game::find(Input::get('game'));
         $gameserver = new Gameserver();
         $gameserver->fill(Input::all());
         $gameserver->ipport()->associate($ip_port);
         $gameserver->user()->associate($user);
         $gameserver->game()->associate($game);
         $gameserver->save();
         return Redirect::action('GameserverController@index');
     } else {
         return Redirect::action('GameserverController@create')->withErrors($v->getMessageBag());
     }
 }