48 lines
977 B
TypeScript
48 lines
977 B
TypeScript
import Station from '#models/station'
|
|
import { BaseModel, belongsTo, column } from '@adonisjs/lucid/orm'
|
|
import type { BelongsTo } from '@adonisjs/lucid/types/relations'
|
|
import { DateTime } from 'luxon'
|
|
import Line from './line.js'
|
|
|
|
export default class Ticket extends BaseModel {
|
|
@column({ isPrimary: true })
|
|
declare id: number
|
|
|
|
@column()
|
|
declare description: string
|
|
|
|
@column()
|
|
declare model: string
|
|
|
|
@column()
|
|
declare sn: string
|
|
|
|
@column()
|
|
declare stationId: string
|
|
|
|
@column()
|
|
declare lineId: string
|
|
|
|
@column()
|
|
declare status: string
|
|
|
|
@column()
|
|
declare history: string
|
|
|
|
@belongsTo(() => Station, {
|
|
foreignKey: 'station_id',
|
|
})
|
|
declare station: BelongsTo<typeof Station>
|
|
|
|
@belongsTo(() => Line, {
|
|
foreignKey: 'line_id',
|
|
})
|
|
declare line: BelongsTo<typeof Line>
|
|
|
|
@column.dateTime({ autoCreate: true })
|
|
declare createdAt: DateTime
|
|
|
|
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
|
declare updatedAt: DateTime
|
|
}
|