Fixed code style errors
This commit is contained in:
@ -2,12 +2,12 @@ const db = require('../models');
|
||||
const Item = db.items;
|
||||
|
||||
// GET - /item/add
|
||||
exports.getAdd = async function (req, res) {
|
||||
exports.getAdd = async function(req, res) {
|
||||
res.render('item/add.twig');
|
||||
};
|
||||
|
||||
// POST - /item/add
|
||||
exports.postAdd = async function (req, res) {
|
||||
exports.postAdd = async function(req, res) {
|
||||
const item = await Item.create({
|
||||
name: req.body.item_name,
|
||||
serialNumber: req.body.item_serial,
|
||||
@ -24,10 +24,12 @@ exports.postAdd = async function (req, res) {
|
||||
};
|
||||
|
||||
// GET - /item/{id}
|
||||
exports.getItem = async function (req, res) {
|
||||
const item = await Item.findAll({ where: {
|
||||
id: req.params.id,
|
||||
}});
|
||||
exports.getItem = async function(req, res) {
|
||||
const item = await Item.findAll({
|
||||
where: {
|
||||
id: req.params.id,
|
||||
},
|
||||
});
|
||||
|
||||
res.render('item/view.twig', {
|
||||
item: item[0],
|
||||
@ -35,10 +37,12 @@ exports.getItem = async function (req, res) {
|
||||
};
|
||||
|
||||
// GET - /item/{id}/edit
|
||||
exports.getItemEdit = async function (req, res) {
|
||||
const item = await Item.findAll({ where: {
|
||||
id: req.params.id,
|
||||
}});
|
||||
exports.getItemEdit = async function(req, res) {
|
||||
const item = await Item.findAll({
|
||||
where: {
|
||||
id: req.params.id,
|
||||
},
|
||||
});
|
||||
|
||||
res.render('item/edit.twig', {
|
||||
item: item[0],
|
||||
@ -46,14 +50,16 @@ exports.getItemEdit = async function (req, res) {
|
||||
};
|
||||
|
||||
// POST - /item/{id}/edit
|
||||
exports.postItemEdit = async function (req, res) {
|
||||
exports.postItemEdit = async function(req, res) {
|
||||
// fetch item from DB
|
||||
const itemSearch = await Item.findAll({ where: {
|
||||
id: req.params.id,
|
||||
}});
|
||||
const itemSearch = await Item.findAll({
|
||||
where: {
|
||||
id: req.params.id,
|
||||
},
|
||||
});
|
||||
|
||||
// retrieve the item record from the array for ease of use
|
||||
let item = itemSearch[0];
|
||||
const item = itemSearch[0];
|
||||
|
||||
// update item attributes
|
||||
item.name = req.body.item_name;
|
||||
|
Reference in New Issue
Block a user