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_icons = sequelize.define(
    'payment_icons',
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
      },

method: {
        type: DataTypes.ENUM,
      
      

        values: [

"zain_cash",


"visa",


"mastercard",


"cash_on_delivery",


"apple_pay",


"google_pay"

        ],

      },

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_icons.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_icons.belongsTo(db.footer_settings, {
      as: 'footer',
      foreignKey: {
        name: 'footerId',
      },
      constraints: false,
    });



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


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

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



  return payment_icons;
};


