add clothes type to clothes
This commit is contained in:
@@ -5,9 +5,9 @@ defmodule PokemonCouture.Shops.Clothes do
|
||||
schema "clothes" do
|
||||
field :name, :string
|
||||
field :color, :string
|
||||
field :type, :string # shirt, pants, socks, shoes, bag, hat, glasses, accessory
|
||||
field :game, :string
|
||||
field :location, :string
|
||||
|
||||
many_to_many :users, PokemonCouture.Accounts.User, join_through: "ownerships", unique: :true, on_replace: :delete
|
||||
|
||||
timestamps()
|
||||
@@ -16,7 +16,8 @@ defmodule PokemonCouture.Shops.Clothes do
|
||||
@doc false
|
||||
def changeset(clothes, attrs) do
|
||||
clothes
|
||||
|> cast(attrs, [:name, :location, :game, :color])
|
||||
|> validate_required([:name, :location, :game, :color])
|
||||
|> cast(attrs, [:name, :location, :type, :game, :color])
|
||||
|> validate_required([:name, :location, :type, :game, :color])
|
||||
|> validate_format(:type, ~r/(shirt)|(pants)|(socks)|(shoes)|(bag)|(hat)|(glasses)|(accessory)/)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Color</th>
|
||||
<th>Type</th>
|
||||
<th>Game</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
@@ -8,6 +8,7 @@ defmodule PokemonCoutureWeb.Components.ClothesComponent do
|
||||
<tr>
|
||||
<td><%= @clothes.name %></td>
|
||||
<td><%= @clothes.color %></td>
|
||||
<td><%= @clothes.type %></td>
|
||||
<td><%= @clothes.game %></td>
|
||||
|
||||
<td>
|
||||
|
||||
Reference in New Issue
Block a user