/** * 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"); }