2017-12-08 09:58:14 +01:00
|
|
|
defmodule EventosWeb.CategoryView do
|
2018-01-14 17:56:50 +01:00
|
|
|
@moduledoc """
|
|
|
|
View for Categories
|
|
|
|
"""
|
2017-12-08 09:58:14 +01:00
|
|
|
use EventosWeb, :view
|
2018-01-13 23:33:03 +01:00
|
|
|
alias EventosWeb.CategoryView
|
|
|
|
|
|
|
|
def render("index.json", %{categories: categories}) do
|
|
|
|
%{data: render_many(categories, CategoryView, "category.json")}
|
|
|
|
end
|
|
|
|
|
|
|
|
def render("show.json", %{category: category}) do
|
|
|
|
%{data: render_one(category, CategoryView, "category.json")}
|
|
|
|
end
|
|
|
|
|
|
|
|
def render("category.json", %{category: category}) do
|
2018-07-27 10:45:35 +02:00
|
|
|
%{
|
|
|
|
id: category.id,
|
2018-01-13 23:33:03 +01:00
|
|
|
title: category.title,
|
|
|
|
description: category.description,
|
2018-07-27 10:45:35 +02:00
|
|
|
picture: category.picture
|
|
|
|
}
|
2018-01-13 23:33:03 +01:00
|
|
|
end
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|