'use strict';
const { Model } = require('sequelize');
const { defaultKeys, modelDefaults, actionUsers } = require('../sequelize/defaults');
module.exports = (sequelize, DataTypes) => {
  class Landmark extends Model {
    static associate(models) {
      actionUsers(Landmark, models);
      Landmark.belongsTo(models.Branch, {
        targetKey: "branch_id",
        foreignKey: "branch_id",
        as: "branches",
      });
      Landmark.belongsTo(models.Area, {
        targetKey: "area_id",
        foreignKey: "area_id",
        as: "area",
      });
    }
  }

  Landmark.init({
    ...defaultKeys("landmark_id"),
    tbl_ref_id: {
      type: DataTypes.STRING,
      allowNull: true,
    },
    landmark_name: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    landmark_descp: {
      type: DataTypes.STRING,
      allowNull: true,
    },
    active_status: {
      type: DataTypes.BOOLEAN,
      allowNull: false,
      defaultValue: 1,
    },
  }, modelDefaults(sequelize, 'landmarks'));
  return Landmark;
};