After "mix phx.gen.live Biddings Bidding biddings bidding_round:integer amount:integer depot_wish_one:string depot_wish_two:string".
This commit is contained in:
24
lib/beet_round_server/biddings/bidding.ex
Normal file
24
lib/beet_round_server/biddings/bidding.ex
Normal file
@ -0,0 +1,24 @@
|
||||
defmodule BeetRoundServer.Biddings.Bidding do
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
|
||||
@primary_key {:id, :binary_id, autogenerate: true}
|
||||
@foreign_key_type :binary_id
|
||||
schema "biddings" do
|
||||
field :bidding_round, :integer
|
||||
field :amount, :integer
|
||||
field :depot_wish_one, :string
|
||||
field :depot_wish_two, :string
|
||||
field :user_id, :binary_id
|
||||
|
||||
timestamps(type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
def changeset(bidding, attrs, user_scope) do
|
||||
bidding
|
||||
|> cast(attrs, [:bidding_round, :amount, :depot_wish_one, :depot_wish_two])
|
||||
|> validate_required([:bidding_round, :amount, :depot_wish_one, :depot_wish_two])
|
||||
|> put_change(:user_id, user_scope.user.id)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user