mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
@@ -145,7 +145,7 @@ exports.updatePlan = async (req, res) => {
|
|||||||
const plan = await mdl_TierPlans.findByPk(req.params.id);
|
const plan = await mdl_TierPlans.findByPk(req.params.id);
|
||||||
if (!plan) return R.error(res, 'Plan not found.', 404);
|
if (!plan) return R.error(res, 'Plan not found.', 404);
|
||||||
|
|
||||||
const allowed = ['label', 'description', 'features', 'price', 'currency', 'is_active', 'status', 'tier_category_id'];
|
const allowed = ['label', 'description', 'features', 'price', 'currency', 'is_active', 'is_recommended', 'status', 'tier_category_id'];
|
||||||
const updates = {};
|
const updates = {};
|
||||||
for (const k of allowed) {
|
for (const k of allowed) {
|
||||||
if (req.body[k] !== undefined) updates[k] = req.body[k];
|
if (req.body[k] !== undefined) updates[k] = req.body[k];
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ exports.getPlans = async (req, res) => {
|
|||||||
const plans = await mdl_TierPlans.findAll({
|
const plans = await mdl_TierPlans.findAll({
|
||||||
where: { status: 'published' },
|
where: { status: 'published' },
|
||||||
order: [['tier', 'ASC'], ['duration_days', 'ASC']],
|
order: [['tier', 'ASC'], ['duration_days', 'ASC']],
|
||||||
attributes: ['plan_id', 'tier', 'label', 'description', 'features', 'duration_days', 'duration_unit', 'price', 'currency', 'is_active'],
|
attributes: ['plan_id', 'tier', 'label', 'description', 'features', 'duration_days', 'duration_unit', 'price', 'currency', 'is_active', 'is_recommended'],
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
model: Course,
|
model: Course,
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
async up(queryInterface, Sequelize) {
|
||||||
|
await queryInterface.addColumn('tier_plans', 'is_recommended', {
|
||||||
|
type: Sequelize.BOOLEAN,
|
||||||
|
allowNull: false,
|
||||||
|
defaultValue: false,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
async down(queryInterface) {
|
||||||
|
await queryInterface.removeColumn('tier_plans', 'is_recommended');
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -21,6 +21,7 @@ const mdl_TierPlans = sequelize.define('TierPlan', {
|
|||||||
price: { type: DataTypes.DECIMAL(10, 2), allowNull: false, label: 'Price' },
|
price: { type: DataTypes.DECIMAL(10, 2), allowNull: false, label: 'Price' },
|
||||||
currency: { type: DataTypes.CHAR(3), allowNull: false, defaultValue: 'USD', label: 'Currency' },
|
currency: { type: DataTypes.CHAR(3), allowNull: false, defaultValue: 'USD', label: 'Currency' },
|
||||||
is_active: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: true, label: 'Active' },
|
is_active: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: true, label: 'Active' },
|
||||||
|
is_recommended: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false, label: 'Recommended', comment: 'Highlights this plan with the "Recommended for you" banner on the client Plans page.' },
|
||||||
status: { type: DataTypes.ENUM('draft', 'published'), allowNull: false, defaultValue: 'draft', label: 'Status', hidden: false, filterable: true },
|
status: { type: DataTypes.ENUM('draft', 'published'), allowNull: false, defaultValue: 'draft', label: 'Status', hidden: false, filterable: true },
|
||||||
createdBy: { type: DataTypes.BIGINT, allowNull: true },
|
createdBy: { type: DataTypes.BIGINT, allowNull: true },
|
||||||
updatedBy: { type: DataTypes.BIGINT, allowNull: true },
|
updatedBy: { type: DataTypes.BIGINT, allowNull: true },
|
||||||
|
|||||||
Reference in New Issue
Block a user