import { DateTime } from 'luxon'
import { BaseModel, column, belongsTo } from '@adonisjs/lucid/orm'
import type { BelongsTo } from '@adonisjs/lucid/types/relations'
import Talhao from './talhao.js'

export default class Pivo extends BaseModel {
  static table = 'pivos'

  @column({ isPrimary: true })
  declare id: number

  @column()
  declare codigo: string

  @column()
  declare nome: string

  @column()
  declare talhaoId: number

  @column()
  declare tipo: string | null

  @column()
  declare vazao: number | null

  @column()
  declare raioAlcance: number | null

  @column()
  declare isAtivo: boolean

  @column.dateTime({ autoCreate: true })
  declare createdAt: DateTime

  @column.dateTime({ autoCreate: true, autoUpdate: true })
  declare updatedAt: DateTime

  @belongsTo(() => Talhao)
  declare talhao: BelongsTo<typeof Talhao>
}