2018-01-13 23:33:03 +01:00
|
|
|
defmodule Eventos.Groups.Member do
|
2017-12-08 09:58:14 +01:00
|
|
|
use Ecto.Schema
|
|
|
|
import Ecto.Changeset
|
2018-01-13 23:33:03 +01:00
|
|
|
alias Eventos.Groups.{Member, Group}
|
|
|
|
alias Eventos.Accounts.Account
|
2017-12-08 09:58:14 +01:00
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
|
|
|
|
schema "members" do
|
2017-12-08 09:58:14 +01:00
|
|
|
field :role, :integer
|
|
|
|
belongs_to :group, Group
|
|
|
|
belongs_to :account, Account
|
|
|
|
|
|
|
|
timestamps()
|
|
|
|
end
|
|
|
|
|
|
|
|
@doc false
|
2018-01-13 23:33:03 +01:00
|
|
|
def changeset(%Member{} = member, attrs) do
|
|
|
|
member
|
2017-12-08 09:58:14 +01:00
|
|
|
|> cast(attrs, [:role])
|
|
|
|
|> validate_required([:role])
|
|
|
|
end
|
|
|
|
end
|