Files
Claper/lib/claper/polls/poll_vote.ex
2022-07-23 01:44:03 +02:00

22 lines
501 B
Elixir

defmodule Claper.Polls.PollVote do
use Ecto.Schema
import Ecto.Changeset
schema "poll_votes" do
field :attendee_identifier, :string
belongs_to :poll, Claper.Polls.Poll
belongs_to :poll_opt, Claper.Polls.PollOpt
belongs_to :user, Claper.Accounts.User
timestamps()
end
@doc false
def changeset(poll_vote, attrs) do
poll_vote
|> cast(attrs, [:attendee_identifier, :user_id, :poll_opt_id, :poll_id])
|> validate_required([:poll_opt_id, :poll_id])
end
end