import { DateTime } from 'luxon'
import { BaseModel, column, belongsTo, manyToMany } from '@adonisjs/lucid/orm'
import type { BelongsTo, ManyToMany } from '@adonisjs/lucid/types/relations'
import Category from '#models/category'
import RestaurantMenu from '#models/restaurant_menu'

export default class RestaurantMenuItem 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

  @column()
  declare priceSmall: number

  @column()
  declare priceLarge: number

  @column()
  declare description: string | null

  @column({ columnName: 'description_hu' })
  declare descriptionHu: string | null

  @column({ columnName: 'description_en' })
  declare descriptionEn: string | null

  @column({ columnName: 'category_id' })
  declare categoryId: number | null

  @belongsTo(() => Category)
  declare category: BelongsTo<typeof Category>

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