2024-01-16 20:54:44 -06:00
|
|
|
class Participant < ApplicationRecord
|
2024-01-22 22:57:37 -06:00
|
|
|
# Associations
|
2024-01-19 23:38:15 -06:00
|
|
|
belongs_to :employer, optional: true
|
2024-01-22 22:57:37 -06:00
|
|
|
has_many :employments
|
|
|
|
has_many :workers, through: :employments
|
2024-01-31 02:19:24 -06:00
|
|
|
has_many :service_contracts
|
|
|
|
has_many :vendors, through: :service_contracts
|
2024-02-02 23:12:36 -06:00
|
|
|
has_many :employer_records
|
|
|
|
has_many :employers, through: :employer_records
|
|
|
|
|
2024-01-22 22:57:37 -06:00
|
|
|
|
|
|
|
# Validations
|
2024-01-20 00:28:17 -06:00
|
|
|
validates :first_name, presence: true
|
|
|
|
validates :last_name, presence: true
|
2024-02-02 16:44:50 -06:00
|
|
|
def full_name
|
|
|
|
"#{first_name} #{last_name}"
|
|
|
|
end
|
2024-01-19 23:38:15 -06:00
|
|
|
|
|
|
|
# Other associations
|
2024-01-16 20:54:44 -06:00
|
|
|
has_and_belongs_to_many :programs
|
|
|
|
end
|