public function status()
 {
     if (Session::has('user_id')) {
         $param['pageNo'] = 2;
         $param['queues'] = QueueModel::whereRaw('DATE(created_at) = DATE(NOW()) AND user_id = ' . Session::get('user_id'))->get();
         return View::make('user.queue.status')->with($param);
     } else {
         return View::make('user.auth.login');
     }
 }
 public function detail($id)
 {
     $param['store'] = StoreModel::find($id);
     $param['servedCount'] = QueueModel::where('store_id', $id)->count();
     $userId = Session::has('user_id') ? Session::get('user_id') : 0;
     $queueNo = QueueModel::where('user_id', $userId)->where('store_id', $id)->whereRaw('DATE(created_at) = DATE(NOW())')->orderBy('created_at', 'DESC')->get();
     if (count($queueNo) > 0) {
         $queueNo = $queueNo[0]->queue_no;
     } else {
         $queueNo = null;
     }
     $param['queueNo'] = $queueNo;
     return View::make('user.store.detail')->with($param);
 }
 public function detail()
 {
     if (Input::has('store_id') && Input::has('user_id')) {
         $storeId = Input::get('store_id');
         $userId = Input::get('user_id');
         $store = StoreModel::find($storeId);
         $queueNo = QueueModel::where('user_id', $userId)->where('store_id', $storeId)->whereRaw('DATE(created_at) = DATE(NOW())')->orderBy('created_at', 'DESC')->get();
         if (count($queueNo) > 0) {
             $queueNo = $queueNo[0]->queue_no;
         } else {
             $queueNo = null;
         }
         return Response::json(['result' => 'success', 'msg' => '', 'store_name' => $store->name, 'company_name' => $store->company->name, 'company_logo' => HTTP_LOGO_PATH . $store->company->setting->logo, 'company_created_at' => $store->company->created_at->format('Y-m-d H:i:s'), 'estimated_waiting' => count($store->activeAgent) == 0 ? '---' : ceil(($store->status->last_queue_no - $store->status->current_queue_no) / count($store->activeAgent)) * ($store->company->setting->waiting_time / 60) . 'min', 'next_number' => $store->status->last_queue_no, 'description' => str_replace('src="/assets', 'src="' . HTTP_PATH . '/assets', $store->description), 'category_name' => $store->company->category->name, 'city_name' => $store->company->city->name, 'address' => $store->address, 'total_customers_served' => QueueModel::where('store_id', $storeId)->count(), 'current_number' => $store->status->current_queue_no, 'queue_no' => $queueNo]);
     } else {
         return Response::json(['result' => 'failed', 'msg' => 'Invalid Request']);
     }
 }
 public function status()
 {
     if (Input::has('user_id')) {
         $queues = QueueModel::whereRaw('DATE(created_at) = DATE(NOW()) AND user_id = ' . Input::get('user_id'))->get();
         $stores = [];
         foreach ($queues as $queue) {
             if (count($queue->store->activeAgent) == 0) {
                 $time = '---';
             } elseif ($queue->queue_no - $queue->store->status->current_queue_no < 0) {
                 $time = 'Passed';
             } else {
                 $time = ceil(($queue->queue_no - $queue->store->status->current_queue_no) / count($queue->store->activeAgent)) * ($queue->store->company->setting->waiting_time / 60) . 'min';
             }
             $stores[] = ['store_id' => $queue->store->id, 'store_name' => $queue->store->name, 'company_name' => $queue->store->company->name, 'address' => $queue->store->address, 'estimated_waiting' => $time, 'current' => $queue->store->status->current_queue_no, 'mine' => $queue->queue_no];
         }
         return Response::json(['result' => 'success', 'msg' => '', 'stores' => $stores]);
     } else {
         return Response::json(['result' => 'failed', 'msg' => 'Invalid Request']);
     }
 }