mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-14 20:19:26 +01:00
change message to translation
This commit is contained in:
@@ -11,7 +11,7 @@ export default class AnnouncesController {
|
||||
const announce = await Announce
|
||||
.query()
|
||||
.orderBy('created_at', 'desc')
|
||||
.preload('message')
|
||||
.preload('translation')
|
||||
.preload('cover')
|
||||
.first()
|
||||
return response.status(200).send({
|
||||
@@ -24,7 +24,7 @@ export default class AnnouncesController {
|
||||
const announce = await Announce.create(data)
|
||||
|
||||
const translation = await getTranslation(data.code)
|
||||
await announce.related('message').associate(translation)
|
||||
await announce.related('translation').associate(translation)
|
||||
|
||||
const cover = await File.findBy('label', data.cover)
|
||||
if (cover) await announce.related('cover').save(cover)
|
||||
@@ -46,7 +46,7 @@ export default class AnnouncesController {
|
||||
|
||||
if (data.code) {
|
||||
const translation = await getTranslation(data.code)
|
||||
await announce.related('message').associate(translation)
|
||||
await announce.related('translation').associate(translation)
|
||||
}
|
||||
|
||||
const cover = await File.findBy('label', data.cover)
|
||||
|
||||
@@ -13,13 +13,11 @@ export default class Announce extends BaseModel {
|
||||
@column()
|
||||
public hoverColor: string
|
||||
|
||||
@belongsTo(() => Translation, {
|
||||
foreignKey: 'translationId'
|
||||
})
|
||||
public message: BelongsTo<typeof Translation>
|
||||
@belongsTo(() => Translation)
|
||||
public translation: BelongsTo<typeof Translation>
|
||||
|
||||
@column()
|
||||
public messageId: number
|
||||
public translationId: number
|
||||
|
||||
@hasOne(() => File)
|
||||
public cover: HasOne<typeof File>
|
||||
|
||||
Reference in New Issue
Block a user