import { PlanSchema } from '#database/schema'
import { belongsTo, hasMany } from '@adonisjs/lucid/orm'
import type { BelongsTo, HasMany } from '@adonisjs/lucid/types/relations'
import Organization from '#models/organization'
import PlanStep from '#models/plan_step'
import Invoice from '#models/invoice'

export default class Plan extends PlanSchema {
  @belongsTo(() => Organization)
  declare organization: BelongsTo<typeof Organization>

  @hasMany(() => PlanStep, { foreignKey: 'planId' })
  declare steps: HasMany<typeof PlanStep>

  @hasMany(() => Invoice)
  declare invoices: HasMany<typeof Invoice>
}
