const config = require('../../config');
const providers = config.providers;
const crypto = require('crypto');
const bcrypt = require('bcrypt');
const moment = require('moment');

module.exports = function(sequelize, DataTypes) {
  const payment_badges = sequelize.define(
    'payment_badges',
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
      },

method: {
        type: DataTypes.ENUM,
      
      

        values: [

"zain_cash",


"visa",


"mastercard",


"cash_on_delivery",


"amex",


"paypal"

        ],

      },

label: {
        type: DataTypes.TEXT,
      
      

      },

is_active: {
        type: DataTypes.BOOLEAN,
      
        allowNull: false,
        defaultValue: false,
      
      

      },

sort_order: {
        type: DataTypes.INTEGER,
      
      

      },

      importHash: {
        type: DataTypes.STRING(255),
        allowNull: true,
        unique: true,
      },
    },
    {
      timestamps: true,
      paranoid: true,
      freezeTableName: true,
    },
  );

  payment_badges.associate = (db) => {


/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity












































//end loop



    db.payment_badges.belongsTo(db.footer_content_blocks, {
      as: 'footer_content_block',
      foreignKey: {
        name: 'footer_content_blockId',
      },
      constraints: false,
    });



    db.payment_badges.hasMany(db.file, {
      as: 'icon_image',
      foreignKey: 'belongsToId',
      constraints: false,
      scope: {
        belongsTo: db.payment_badges.getTableName(),
        belongsToColumn: 'icon_image',
      },
    });


    db.payment_badges.belongsTo(db.users, {
      as: 'createdBy',
    });

    db.payment_badges.belongsTo(db.users, {
      as: 'updatedBy',
    });
  };



  return payment_badges;
};


