Add Articles

mix phx.gen.live Articles Article articles title:string\                                                            /Crucial/git/phoenix-liveview-book
  content:text url:string language:string\
  date:utc_datetime author_id:references:authors
This commit is contained in:
Thelonius Kort
2022-12-26 18:02:29 +01:00
parent 005a9d9337
commit f7f1e1a284
13 changed files with 582 additions and 0 deletions

View File

@ -0,0 +1,24 @@
defmodule Outlook.Articles.Article do
use Ecto.Schema
import Ecto.Changeset
alias Outlook.Authors.Author
schema "articles" do
field :content, :string
field :date, :utc_datetime
field :language, :string
field :title, :string
field :url, :string
belongs_to :author, Author
timestamps()
end
@doc false
def changeset(article, attrs) do
article
|> cast(attrs, [:title, :content, :url, :language, :date])
|> validate_required([:title, :content, :url, :language, :date])
end
end