public function chat($id, $request)
 {
     if (UserChannel::exists(array('name' => $id))) {
         $data = [];
         $channel = UserChannel::find(['name' => $id]);
         $data['channel'] = $channel;
         $access = LiveAccess::find(array('channel_id' => $channel->id));
         if (is_object($access)) {
             $data['viewers'] = $access->viewers;
         } else {
             $data['viewers'] = 0;
         }
         return new ViewResponse('embed/chat', $data, false);
     } else {
         return Utils::getNotFoundResponse();
     }
 }
 public function lives($request)
 {
     $data = array();
     $data['lives'] = LiveAccess::getOnlines();
     return new ViewResponse('news/lives', $data);
 }
Exemple #3
0
 public static function getOnlines()
 {
     return LiveAccess::all(array('conditions' => array('online' => 1)));
 }
Exemple #4
0
 public function hasLiveAccess()
 {
     return LiveAccess::exists(array('channel_id' => $this->id));
 }
 public function viewers($id, $request)
 {
     if (UserChannel::exists($id)) {
         $channel_id = $id;
     } elseif (UserChannel::exists(array('name' => $id))) {
         $channel_id = UserChannel::find(array('name' => $id))->id;
     } else {
         return Utils::getNotFoundResponse();
     }
     return new JsonResponse(array(LiveAccess::find(array('channel_id' => $channel_id))->viewers));
 }