public function edit($id)
 {
     try {
         $server = Server::findOrFail($id);
         // If no setting entry exists for the server we need to create it
         if (is_null($server->setting)) {
             $setting = new Setting(['server_id' => $id]);
             $setting->server()->associate($server)->save();
             $server->load('setting');
         }
         Former::populate($server->setting);
         return View::make('admin.site.servers.edit', compact('server'))->with('page_title', 'Server Settings');
     } catch (ModelNotFoundException $e) {
         return Redirect::route('admin.site.servers.index')->withErrors(['Server doesn\'t exist.']);
     }
 }
Exemple #2
0
 public function edit($id)
 {
     try {
         $server = Server::findOrFail($id);
         // If no setting entry exists for the server we need to create it
         if (is_null($server->setting)) {
             try {
                 $battlelog = App::make('BFACP\\Libraries\\Battlelog\\BattlelogServer')->server($server);
                 $serverguid = $battlelog->guid();
             } catch (Exception $e) {
                 $serverguid = null;
                 Session::flash('warnings', ['Unable to automatically get the battlelog server guid. Please manually enter it.']);
             }
             $setting = new Setting(['server_id' => $id, 'battlelog_guid' => $serverguid]);
             $setting->server()->associate($server)->save();
             $server->load('setting');
         }
         Former::populate($server->setting);
         return View::make('admin.site.servers.edit', compact('server'))->with('page_title', 'Server Settings');
     } catch (ModelNotFoundException $e) {
         return Redirect::route('admin.site.servers.index')->withErrors(['Server doesn\'t exist.']);
     }
 }