/** * list function. * * @description Listado de las notificaciones de la base de datos * @access public * @return void */ public function getIndex() { $limit = Input::get('limit', 10); $page = Input::get('page', 1) - 1; $search = Input::get('search', ''); $order = Input::get('order', 'id|asc'); $rows = Notification::leftJoin('coupons', 'notifications.coupon_id', '=', 'coupons.id'); if ($search != "") { $where_search = '(message LIKE ? OR title LIKE ?)'; $registers->whereRaw($where_search, array("%{$search}%", "%{$search}%")); $total = $rows->count(); } else { $total = $rows->count(); } $order = explode("|", $order); $rows->take($limit)->skip($page * $limit)->orderBy($order[0], $order[1]); $rows = $rows->get(array('notifications.*', 'coupons.title')); $devices = DB::table('user_users_tokens')->count(); $coupons = Coupon::orderBy('title', 'ASC')->select('coupons.*')->lists('title', 'id'); return View::make('admin.notifications.index')->with("rows", $rows)->with("devices", $devices)->with("coupons", $coupons)->with("search", $search)->with("page", $page)->with("limit", $limit)->with("total", $total)->with("show", min(($page + 1) * $limit, $total))->with("torder", $order[1] == "asc" ? "desc" : "asc"); }
/** * getDashboard * * regresa la informacion del escritorio del usuario * * @access public * @params * @return json * @autor Fernando Saavedra * * https://secure.kreativeco.com/se-banamex/api/dashboard * */ public function getDashboard() { $request = Request::all(); $user = Auth::user(); if ($user === null) { return Response::json(array("success" => true, "service" => __FUNCTION__, "error" => true, "message" => "Token no valido")); } $limit = 1; $coupon = Coupon::orderBy('id', 'DESC')->take($limit)->get(); $notification = Notification::where('notifications.id', '>', $request["notification_id"])->where('notifications.notification_type', '=', 1)->orderBy('id', 'DESC')->take(1)->get(); $notificationList = Notification::where('notifications.id', '>', $request["notification_id"])->orderBy('id', 'DESC')->get(); //dd( count($notificationList) ); return Response::json(array("success" => true, "service" => __FUNCTION__, "coupon" => $coupon, "notification" => $notification, "notification_list" => $notificationList, "count" => count($notificationList))); }