Packages

This is a CMS written in Elixir. Aims to be the great open-source ecommerce and/or startup solution for those who are searching for a performance and stability on top of modern technologies like React and Elixir.

Current section

Files

Jump to
lyn web models language.ex
Raw

web/models/language.ex

defmodule Lyn.Language do
use Lyn.Web, :model
schema "languages" do
field :sort_order, :integer
field :name, :string
field :abbr, :string
field :charset, :string
timestamps
end
def admin_fields do
[
id: %{
label: "id",
type: :integer
},
name: %{
label: "name",
type: :string
},
abbr: %{
label: "abbr",
type: :string
},
charset: %{
label: "charset",
type: :string
},
sort_order: %{
label: "sort_order",
type: :integer
}
]
end
@required_fields ~w(name abbr charset)
@optional_fields ~w(sort_order)
@doc """
Creates a changeset based on the `model` and `params`.
If no params are provided, an invalid changeset is returned
with no validation performed.
"""
def changeset(model, params \\ :empty) do
model
|> cast(params, @required_fields, @optional_fields)
end
end