2019-10-26 11:31:19 +11:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2019-12-04 11:23:45 +11:00
|
|
|
module DiscourseSubscriptions
|
2019-10-26 11:31:19 +11:00
|
|
|
class Customer < ActiveRecord::Base
|
2019-12-03 13:29:47 +11:00
|
|
|
self.table_name = "discourse_subscriptions_customers"
|
|
|
|
|
|
2019-10-26 13:01:49 +11:00
|
|
|
scope :find_user, ->(user) { find_by_user_id(user.id) }
|
|
|
|
|
|
2020-05-22 11:20:05 -05:00
|
|
|
has_many :subscriptions
|
|
|
|
|
|
2019-12-03 13:29:47 +11:00
|
|
|
def self.create_customer(user, customer)
|
|
|
|
|
create(customer_id: customer[:id], user_id: user.id)
|
2019-10-26 13:01:49 +11:00
|
|
|
end
|
2019-10-26 11:31:19 +11:00
|
|
|
end
|
|
|
|
|
end
|
2024-10-25 05:48:56 -03:00
|
|
|
|
|
|
|
|
# == Schema Information
|
|
|
|
|
#
|
|
|
|
|
# Table name: discourse_subscriptions_customers
|
|
|
|
|
#
|
|
|
|
|
# id :bigint not null, primary key
|
|
|
|
|
# customer_id :string not null
|
|
|
|
|
# product_id :string
|
|
|
|
|
# user_id :bigint
|
|
|
|
|
# created_at :datetime not null
|
|
|
|
|
# updated_at :datetime not null
|
|
|
|
|
#
|
|
|
|
|
# Indexes
|
|
|
|
|
#
|
|
|
|
|
# index_discourse_subscriptions_customers_on_customer_id (customer_id)
|
|
|
|
|
# index_discourse_subscriptions_customers_on_user_id (user_id)
|
|
|
|
|
#
|