import { DateTime } from 'luxon'
import { BaseModel, column, hasMany } from '@adonisjs/lucid/orm'
import type { HasMany } from '@adonisjs/lucid/types/relations'
import RestaurantMenuItem from '#models/restaurant_menu_item'

export default class Category extends BaseModel {
  @column({ isPrimary: true })
  declare id: number

  @column()
  declare name: string

  @column({ columnName: 'name_hu' })
  declare nameHu: string | null

  @column({ columnName: 'name_en' })
  declare nameEn: string | null

  @column()
  declare slug: string

  @hasMany(() => RestaurantMenuItem)
  declare menuItems: HasMany<typeof RestaurantMenuItem>

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

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