add menu in create and update product admin
This commit is contained in:
@@ -58,6 +58,9 @@ module.exports.create = [
|
||||
body('category')
|
||||
.notEmpty().withMessage(_sr['fa'].required.category),
|
||||
|
||||
body('menuType_id')
|
||||
.notEmpty().withMessage(_sr['fa'].required.menuType_id),
|
||||
|
||||
body('havePoint')
|
||||
.optional().isBoolean().withMessage(_sr['fa'].format.boolean),
|
||||
|
||||
@@ -87,8 +90,8 @@ module.exports.create = [
|
||||
async (req, res) => {
|
||||
if (req.files?.image && !_sr.supportedImageFormats.includes(req.files.image.mimetype.split('/')[1])) return res.status(422).json({validation: {image: {msg: _sr['fa'].format.image}}})
|
||||
|
||||
const {name, description, short_description, price, stock, static_discount, estimated_time, category, index, special, havePoint, club, point, sale , branchId} = req.body
|
||||
const data = {name, description, short_description, price, stock, static_discount, estimated_time, category, index, special, havePoint, club, point, sale , branchId}
|
||||
const {name, description, short_description, price, stock, static_discount, estimated_time, category, index, special, havePoint, club, point, sale , branchId, menuType_id} = req.body
|
||||
const data = {name, description, short_description, price, stock, static_discount, estimated_time, category, index, special, havePoint, club, point, sale , branchId, menuType_id}
|
||||
|
||||
if (req?.files?.image) {
|
||||
const image = req?.files?.image
|
||||
@@ -143,6 +146,16 @@ module.exports.getAllForWebSite = [
|
||||
}
|
||||
}
|
||||
]
|
||||
module.exports.getAllRestaurant = [
|
||||
async (req, res) => {
|
||||
try {
|
||||
const allFoods = await Food.find().select('-ratings').sort({index: 1});
|
||||
return res.json(allFoods);
|
||||
} catch (error) {
|
||||
return res500(res, _sr['fa'].response.unknownError);
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
module.exports.getAllForPanel = [
|
||||
async (req, res) => {
|
||||
@@ -267,8 +280,8 @@ module.exports.update = [
|
||||
async (req, res) => {
|
||||
if (req.files?.image && !_sr.supportedImageFormats.includes(req.files.image.mimetype.split('/')[1])) return res.status(422).json({validation: {image: {msg: _sr['fa'].format.image}}})
|
||||
|
||||
const {name, description, short_description, price, stock, static_discount, estimated_time, category, index, special, havePoint, club, point, sale , branchId} = req.body
|
||||
const data = {name, description, short_description, price, stock, static_discount, estimated_time, category, index, special, havePoint, club, point, sale , branchId}
|
||||
const {name, description, short_description, price, stock, static_discount, estimated_time, category, index, special, havePoint, club, point, sale , branchId, menuType_id} = req.body
|
||||
const data = {name, description, short_description, price, stock, static_discount, estimated_time, category, index, special, havePoint, club, point, sale , branchId, menuType_id}
|
||||
|
||||
if (req.files?.image) {
|
||||
const image = req.files.image
|
||||
|
||||
Reference in New Issue
Block a user