class Admins::ShixunFeedbackMessagesController < Admins::BaseController

  def index
    @params_page = params[:page] || 1
    if params[:keyword].present?
      discusses = Discuss.joins("LEFT JOIN shixuns ON discusses.dis_id = shixuns.id AND dis_type = 'Shixun'")
                      .where("shixuns.name like ?", "%#{params[:keyword]}%")
    else
      discusses = Discuss.where(:dis_type => 'Shixun').includes(:user, :dis)
    end

    if params[:begin_date].present?
      discusses = discusses.where("discusses.created_at > ?", params[:begin_date])
    end

    if params[:end_date].present?
      discusses = discusses.where("discusses.created_at < ?", params[:end_date])
    end

    @discusses = paginate discusses.order("created_at desc")
  end
end