Submitted by rahmansubrata12 in nodejs

saya mengikuti tutorial pengerjaan final projek tapi untuk melakukan booking selalu menyimpan 2 data sekaligus pada database seperti pada gambar.

public async store ({request,response,params,auth}: HttpContextContract) { const field = await Field.findByOrFail('id',params.field_id) const user=auth.user! const payload = await request.validate(FormbookingValidator) const booking= new Booking() booking.playDateStart = payload.play_date_start booking.playDateEnd = payload.play_date_end booking.title = payload.title let data=user.related('myBooking').save(booking) let data2=booking.related('field').associate(field) console.log(data,data2)

return response.created({status:'success', data:booking})

}

1

Comments

You must log in or register to comment.

There's nothing here…