Exemple #1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function postOnlinephonelist()
 {
     $token = Input::only('token');
     $user_id = $this->_getUserId($token['token']);
     $online_phone = [];
     if ($user_id) {
         $status = $this->_getUserStatus($user_id);
         if ($status == 2) {
             //$online_phone = OnlinePhone::all();
         } elseif ($status == 3) {
             $domain = Domain::whereUserId($user_id)->get(array('sip_server'));
             $sip_server = array();
             foreach ($domain as $row) {
                 $sip_server[] = $row['sip_server'];
             }
             if ($sip_server) {
                 $online_phone = OnlinePhone::whereIn('sip_server', $sip_server)->get();
             } else {
                 $online_phone = [];
             }
             $error = array(0, "");
         } else {
             //$sip_server = Domain::whereUserId($user_id)->first()->sip_server;
             //$online_phone = OnlinePhone::whereSipServer($sip_server)->get();
         }
     } else {
         $error = array(403, "Invalid Token");
     }
     return View::make('api.onlinephonelist')->with('online_phone', $online_phone)->with('error', $error);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function getIndex()
 {
     $status = Auth::user()->status;
     if ($status == 2) {
         $online_phone = OnlinePhone::all();
     } elseif ($status == 3) {
         $domain = Domain::whereUserId(Auth::user()->id)->get(array('sip_server'));
         $sip_server = array();
         foreach ($domain as $row) {
             $sip_server[] = $row['sip_server'];
         }
         if ($sip_server) {
             $online_phone = OnlinePhone::whereIn('sip_server', $sip_server)->get();
         } else {
             $online_phone = [];
         }
     } else {
         $sip_server = Domain::find(Cookie::get('domain_hash'))->sip_server;
         $online_phone = OnlinePhone::whereSipServer($sip_server)->get();
     }
     return View::make('online_phone.index')->with('online_phones', $online_phone);
 }