Class: Dashboard::V2::Group::VoucherMarketplacesController
- Inherits:
-
VoucherMarketplacesController
- Object
- ActionController::Base
- ApplicationController
- MainController
- VoucherMarketplacesController
- Dashboard::V2::Group::VoucherMarketplacesController
- Defined in:
- app/controllers/dashboard/v2/group/voucher_marketplaces_controller.rb
Overview
typed: ignore
Instance Method Summary collapse
- #edit_history ⇒ Object
- #history ⇒ Object
- #list ⇒ Object
- #redeem ⇒ Object
- #search_history ⇒ Object
- #search_list ⇒ Object
Methods inherited from VoucherMarketplacesController
#check_owner_ticket, #check_voucher, #get_redeem_history, #get_redeem_list, #redeem_history, #redeem_list, #self_redeem, #self_redeem_form
Methods inherited from MainController
#default_fallback_location, #default_url_options, #kiosque_callback
Methods included from LogrageCustomLogger
Methods included from Stimulus::TagController
Methods included from OwnerLoginMode
#current_owner, #group_owner_type?, #request_path_contain_group?, #single_owner_type?
Methods included from OwnerDashboardsHelper
#events_ajax_previous_link, #show_source
Methods inherited from ApplicationController
#after_sign_in_path_for, #after_sign_out_path_for, #default_url_options, #identity_cache_memoization, #render_not_found, #routing_error, search_params_key=
Methods included from ControllerHelpers
#check_boolean_param, #get_banners, #inventory_params, #reservation_params
Instance Method Details
#edit_history ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/controllers/dashboard/v2/group/voucher_marketplaces_controller.rb', line 55 def edit_history ActiveRecord::Base.transaction do ticket = Ticket.find_by(ticket_code: params[:code]) if ticket.present? ticket.name = params[:name] ticket.phone = params[:phone] if ticket.save! redirect_to :history_dashboard_v2_group_voucher_marketplaces, notice: 'Data Updated' else redirect_to :history_dashboard_v2_group_voucher_marketplaces, notice: 'Failed to Update' end else redirect_to :history_dashboard_v2_group_voucher_marketplaces, notice: 'Failed to Update' end end end |
#history ⇒ Object
37 38 39 40 41 |
# File 'app/controllers/dashboard/v2/group/voucher_marketplaces_controller.rb', line 37 def history @data = Ticket.joins(:ticket_transaction). where(ticket_transactions: { restaurant_id: current_owner.restaurant_ids }). where.not(redeemed_at: nil) end |
#list ⇒ Object
6 7 8 9 |
# File 'app/controllers/dashboard/v2/group/voucher_marketplaces_controller.rb', line 6 def list @data = TicketGroup.joins(:restaurants). where(ticket_group_restaurants: { restaurant_id: current_owner.restaurant_ids }) end |
#redeem ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/dashboard/v2/group/voucher_marketplaces_controller.rb', line 22 def redeem service = TicketService::Redeem.new( code: params[:code], name: params[:name], phone: params[:phone], guest_detail: params[:guest_detail], ) if service.execute redirect_to :list_dashboard_v2_group_voucher_marketplaces, notice: 'Voucher has been redeemed successfully' else redirect_to :list_dashboard_v2_group_voucher_marketplaces, alert: service.errors..to_sentence end end |
#search_history ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/controllers/dashboard/v2/group/voucher_marketplaces_controller.rb', line 43 def search_history if params[:restaurant_id] == 'all' @data = history elsif current_owner.restaurant_ids.include? params[:restaurant_id].to_i @data = Ticket.joins(:ticket_transaction). where(ticket_transactions: { restaurant_id: params[:restaurant_id] }). where.not(redeemed_at: nil) else redirect_to :history_dashboard_v2_group_voucher_marketplaces, notice: 'Restaurant not found' end end |
#search_list ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/dashboard/v2/group/voucher_marketplaces_controller.rb', line 11 def search_list if params[:restaurant_id] == 'all' @data = list elsif current_owner.restaurant_ids.include? params[:restaurant_id].to_i @data = TicketGroup.joins(:restaurants). where(ticket_group_restaurants: { restaurant_id: params[:restaurant_id] }) else redirect_to :list_dashboard_v2_group_voucher_marketplaces, notice: 'Restaurant not found' end end |