pokemon-couture/lib/pokemon_couture/shops/clothes.ex

23 lines
519 B
Elixir
Raw Normal View History

defmodule PokemonCouture.Shops.Clothes do
use Ecto.Schema
import Ecto.Changeset
schema "clothes" do
2021-06-30 14:03:08 +02:00
field :name, :string
field :color, :string
field :game, :string
field :location, :string
2021-06-30 14:03:08 +02:00
many_to_many :users, PokemonCouture.Accounts.User, join_through: "ownerships", unique: :true
timestamps()
end
@doc false
def changeset(clothes, attrs) do
clothes
2021-06-30 14:03:08 +02:00
|> cast(attrs, [:name, :location, :game, :color])
|> validate_required([:name, :location, :game, :color])
end
end