Esempio n. 1
0
 /**
  * Gathers the population for all servers
  *
  * @param $id
  *
  * @return array
  */
 public function chat($id)
 {
     $chat = Chat::with('player')->where('ServerID', $id);
     if (Input::has('nospam') && Input::get('nospam') == 1) {
         $chat = $chat->excludeSpam();
     }
     if (Input::has('sb') && Input::get('sb') == 1) {
         $chat = $chat->orderBy('logDate', 'desc')->take(100)->get();
     } else {
         $chat = $chat->simplePaginate(30);
     }
     return MainHelper::response($chat, null, null, null, false, true);
 }
Esempio n. 2
0
 /**
  * Returns the player chatlogs
  * @param  integer $id    Player ID
  * @param  integer $limit Results to return
  * @return object
  */
 public function getPlayerChat($id, $limit = 30)
 {
     $chatlogs = Chat::with('server')->where('logPlayerID', $id)->excludeSpam()->orderBy('logDate', 'desc');
     // If a server is specifed then we only pull logs from that server
     if (Input::has('server')) {
         $serverId = Input::get('server', null);
         if (!is_null($serverId) && is_numeric($serverId) && $serverId > 0) {
             $chatlogs->where('ServerID', $serverId);
         }
     }
     // If user has entered keywords only pull logs that contain those keywords
     if (Input::has('keywords')) {
         $keywords = trim(Input::get('keywords', null));
         if (!is_null($keywords) && $keywords != '') {
             // Remove spaces before and after the comma
             $keywords = preg_replace('/\\s*,\\s*/', ',', $keywords);
             // Explode into an array
             $keywords = explode(',', $keywords);
             $chatlogs->where(function ($query) use($keywords) {
                 foreach ($keywords as $keyword) {
                     $query->orWhere('logMessage', 'LIKE', '%' . $keyword . '%');
                 }
             });
         }
     }
     return $chatlogs->paginate($limit);
 }