Sha256: 277ed6a41868ec94d0f87341322d8d95a1bf88cb11c2627f767a915e1e6092ba

Contents?: true

Size: 965 Bytes

Versions: 1

Compression:

Stored size: 965 Bytes

Contents

# frozen_string_literal: true

module SolidusPromotions
  class PromotionCategoriesController < SolidusAdmin::BaseController
    include SolidusAdmin::ControllerHelpers::Search

    def index
      promotion_categories = apply_search_to(
        SolidusPromotions::PromotionCategory.all,
        param: :q
      )

      set_page_and_extract_portion_from(promotion_categories)

      respond_to do |format|
        format.html { render component("solidus_promotions/categories/index").new(page: @page) }
      end
    end

    def destroy
      @promotion_categories = SolidusPromotions::PromotionCategory.where(id: params[:id])

      SolidusPromotions::PromotionCategory.transaction { @promotion_categories.destroy_all }

      flash[:notice] = t(".success")
      redirect_back_or_to solidus_promotions.promotion_categories_path, status: :see_other
    end

    private

    def authorization_subject
      SolidusPromotions::PromotionCategory
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_promotions-4.4.2 lib/controllers/admin/solidus_promotions/promotion_categories_controller.rb