feat: add relatives

This commit is contained in:
Nathan Lamy 2025-08-21 13:34:56 +02:00
parent 9061da4f09
commit e8ca067ae8

View file

@ -53,12 +53,22 @@ export default class CollesController {
return response.notFound({ message: 'Colle not found' })
}
const relatives = await Colle.query()
.where('subjectId', colle.subjectId)
.where('date', colle.date.toISO()!)
.where('id', '!=', colle.id) // Exclude the current colle
.whereHas('student', (query) => {
query.where('className', auth.user!.className)
})
.preload('student')
return {
success: true,
data: {
...colle.serialize(),
bjid: colle.bjid,
bjsecret: colle.bjsecret,
relatives,
},
}
}