26 lines
601 B
TypeScript
26 lines
601 B
TypeScript
import { DateTime } from 'luxon'
|
|
import { BaseModel, column, computed, hasMany } from '@adonisjs/lucid/orm'
|
|
import Course from './course.js'
|
|
import type { HasMany } from '@adonisjs/lucid/types/relations'
|
|
|
|
export default class Meal extends BaseModel {
|
|
@column({ isPrimary: true })
|
|
declare id: number
|
|
|
|
@column()
|
|
declare date: DateTime
|
|
|
|
@column()
|
|
declare type: 0 | 1 // 0 = lunch, 1 = dinner
|
|
|
|
@column()
|
|
declare submittable: boolean
|
|
|
|
@computed()
|
|
get name() {
|
|
return this.type === 0 ? 'Déjeuner' : 'Dîner'
|
|
}
|
|
|
|
@hasMany(() => Course)
|
|
declare courses: HasMany<typeof Course>
|
|
}
|