import { DateTime } from 'luxon'
import { BaseModel, column, hasMany } from '@adonisjs/lucid/orm'
import type { HasMany } from '@adonisjs/lucid/types/relations'
import Pivo from './pivo.js'

export default class Talhao extends BaseModel {
  static table = 'talhoes'

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

  @column()
  declare codigo: string

  @column()
  declare nome: string

  @column()
  declare areaHectares: number

  @column()
  declare cultura: string | null

  @column()
  declare localizacao: string | null

  @column()
  declare isAtivo: boolean

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

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

  @hasMany(() => Pivo)
  declare pivos: HasMany<typeof Pivo>
}
