Chatwoot/app/controllers/public/api/v1/portals/articles_controller.rb

26 lines
528 B
Ruby
Raw Normal View History

2022-07-08 11:54:38 +00:00
class Public::Api::V1::Portals::ArticlesController < ApplicationController
before_action :set_portal
before_action :set_article, only: [:show]
def index
@articles = @portal.articles
2022-07-28 08:29:16 +00:00
@articles = @articles.search(list_params) if list_params.present?
2022-07-08 11:54:38 +00:00
end
def show; end
private
def set_article
@article = @portal.articles.find(params[:id])
end
def set_portal
@portal = ::Portal.find_by!(slug: params[:portal_slug], archived: false)
end
def list_params
2022-07-28 08:29:16 +00:00
params.permit(:query)
2022-07-08 11:54:38 +00:00
end
end