Skip to content

Instantly share code, notes, and snippets.

@shankardevy

shankardevy/customer1.ex Secret

Created Jul 8, 2017
Embed
What would you like to do?
Customer schema module generated by Mix command.
defmodule Mango.CRM.Customer do
use Ecto.Schema
import Ecto.Changeset
alias Mango.CRM.Customer
schema "customers" do
field :email, :string
field :name, :string
field :password_hash, :string
field :phone, :string
field :residence_area, :string
timestamps()
end
@doc false
def changeset(%Customer{} = customer, attrs) do
customer
|> cast(attrs, [:name, :email, :phone, :residence_area, :password_hash])
|> validate_required([:name, :email, :phone, :residence_area, :password_hash])
|> unique_constraint(:email)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment