text: import Registration from '@apps/events/models/registration'
  import Response from '@apps/forms/models/response'
  import Profile from '@apps/maha/models/profile'
  import Asset from '@apps/maha/models/asset'
  import Deal from '@apps/sales/models/deal'
  import knex from '@core/vendor/knex/maha'
  import Model from '@core/objects/model'
  import Program from './program'
  import Contact from './contact'
  import Signer from './signer'
  
  const Agreement = new Model(knex, {
  
    databaseName: 'maha',
  
    tableName: 'crm_agreements',
  
    rules: {},
  
    virtuals: {
  
      adobesign_host() {
        const profile = this.related('profile')
        return profile.get('data').web_access_point
      },
  
      adobesign_agreement_link() {
        return `${this.get('adobesign_host')}public/agreements/view/${this.get('adobesign_agreement_id')}?type=esign`
      },
  
      adobesign_signing_link() {
        return `${this.get('adobesign_host')}/public/apiesign?pid=${this.get('adobesign_signing_id')}&client_id=${process.env.ADOBE_SIGN_CLIENT_ID}`
      }
  
    },
  
    contact() {
      return this.belongsTo(Contact, 'contact_id')
    },
  
    deal() {
      return this.belongsTo(Deal, 'deal_id')
    },
  
    program() {
      return this.belongsTo(Program, 'program_id')
    },
  
    profile() {
      return this.belongsTo(Profile, 'profile_id')
    },
  
    registration() {
      return this.belongsTo(Registration, 'registration_id')
    },
  
    response() {
      return this.belongsTo(Response, 'response_id')
    },
  
    signed() {
      return this.belongsTo(Asset, 'signed_id')
    },
  
    signers() {
      return this.hasMany(Signer, 'agreement_id')
    },
  
    unsigned() {
      return this.belongsTo(Asset, 'unsigned_id')
    }
  
  })
  
  export default Agreement
  