Пример #1
0
 /**
  * Handle the event.
  *
  * @param  ServersUpdate  $event
  * @return void
  */
 public function handle(ServersUpdate $event)
 {
     $servers = Server::all()->where('active', 1);
     if ($servers) {
         foreach ($servers as $server) {
             $data = new SourceQuery();
             try {
                 $engine = $server->engine >= 1 ? 1 : 0;
                 $data->Connect($server->ip, $server->port, 3, $engine);
                 $information = $data->GetInfo();
                 $players = $data->GetPlayers();
                 $rules = $data->GetRules();
             } catch (\Exception $e) {
                 $information = '';
                 $players = '';
                 $rules = '';
             }
             $server->information = json_encode($information);
             $server->players = json_encode($data->GetPlayers($players));
             $server->rules = json_encode($data->GetRules($rules));
             $server->save();
         }
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $servers = Server::all();
     return view('pages.servers.index', compact('servers'));
 }
Пример #3
0
 public function index()
 {
     return view('servers', ['servers' => Server::all()]);
 }