Files
2020-03-06 08:35:12 -05:00

21 lines
686 B
Ruby

module Users
class SuppliersController < Users::ApplicationController
def show
@supplier = Supplier.find(params[:id])
render json: {}, status: :not_found and return unless @supplier.present?
render json: @supplier
end
def product_categories
@supplier = Supplier.find(params[:id])
render json: {}, status: :not_found and return unless @supplier.present?
@supplier.product_categories.include_relations products: :product_variants
render json: @supplier.product_categories, serializer: Users::ProductCategorySerializer, is_collection: true, include: %w[
products
products.product_variants
]
end
end
end