/** * get_list function. * * @description Listado de los comentarios registrados 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', 'comments.created_at|desc'); $rows = Comment::join('user_users', 'comments.user_id', '=', 'user_users.id')->leftJoin('coupons', 'comments.coupon_id', '=', 'coupons.id')->whereNull('user_users.deleted_at')->whereNull('coupons.deleted_at'); if ($search != "") { $where_search = '(username LIKE ? OR comment LIKE ?)'; $rows->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('comments.id', DB::raw('DATE_FORMAT(comments.created_at, "%e/%c/%Y") AS created'), 'comments.comment', 'user_users.email', 'coupons.title')); return View::make('admin.comments.index')->with("rows", $rows)->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"); }
public function get_old_comments() { //获取旧评论 $pagination = Input::get('page'); $order = Input::get('order'); //获取传参 $ex = explode(':', $this->page_id); if (is_array($ex)) { $page_id_pre = $ex[0]; $data = Comment::join('comment_extend', 'comments.id', '=', 'comment_extend.id')->whereRaw("`project_id` = '{$this->project_id}' and `page_id` like '{$page_id_pre}:%' and `page_id` != '{$this->page_id}' and `status` = '1'")->orderBy('comment_extend.top', 'desc')->orderBy('comments.id', 'desc')->paginate($this->project_config['page_num']); } else { $data = Comment::join('comment_extend', 'comments.id', '=', 'comment_extend.id')->whereRaw("`project_id` = '{$this->project_id}' and `page_id` = '{$this->page_id}' and `status` = '1'")->orderBy('comment_extend.top', 'desc')->orderBy('comments.id', 'desc')->paginate($this->project_config['page_num']); } $return_arr['status'] = 0; $return_arr['total'] = $data->Total(); $return_arr['per_page'] = $data->PerPage(); $return_arr['current_page'] = $data->CurrentPage(); $return_arr['last_page'] = $data->LastPage(); $return_arr['data'] = array(); foreach ($data as $row) { if ($row->level >= 2) { $return_arr['data'][] = $this->_get_multi_row($row); } else { $return_arr['data'][] = $row->toArray(); } } return $this->_return_json($return_arr); }