import { DateTime } from 'luxon'
import { BaseModel, column, manyToMany } from '@adonisjs/lucid/orm'
import type { ManyToMany } from '@adonisjs/lucid/types/relations'
import RestaurantMenuItem from './restaurant_menu_item.js'

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

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

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

  @column()
  declare name: string

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

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

  @manyToMany(() => RestaurantMenuItem, {
    pivotTable: 'menu_item_menus',
  })
  declare items: ManyToMany<typeof RestaurantMenuItem>
}
