/** * premium function. * * @description Listado de cupones premium * @access public * @return void */ public function getPremium() { $limit = Input::get('limit', 10); $page = Input::get('page', 1) - 1; $search = Input::get('search', ''); $order = Input::get('order', 'id|desc'); $rows = Coupon::leftJoin('categories', 'coupons.category_id', '=', 'categories.id')->join('coupons_premium', 'coupons.id', '=', 'coupons_premium.coupon_id'); if ($search != "") { $where_search = '(title LIKE ? OR categories.name LIKE ?)'; $coupons->rawWhere($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('coupons.*', 'categories.name as category')); $not_in = $rows->lists("id"); $list = Coupon::whereNotIn('id', $not_in)->orderBy('title', 'ASC')->lists('title', 'id'); return View::make('admin.coupons.premium')->with("rows", $rows)->with("list", $list)->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"); }