Signed-off-by: Arthur DANJOU <arthurdanjou@outlook.fr>
This commit is contained in:
2021-07-02 17:49:06 +02:00
parent b1423cb0c5
commit 8e4bfa178c
5 changed files with 15 additions and 279 deletions

View File

@@ -1,16 +1,24 @@
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
import {HttpContextContract} from '@ioc:Adonis/Core/HttpContext'
import Location from "App/Models/Location";
import LocationValidator from "App/Validators/location/LocationValidator";
export default class LocationsController {
public async get ({ response }: HttpContextContract) {
const location = await Location.query().orderBy('since', 'desc').firstOrFail()
return response.status(200).send({
place: location.place,
left: location.left,
since: location.since
})
const location = await Location.query().orderBy('since', 'desc').first()
if (location) {
return response.status(200).send({
location: {
place: location.place,
left: location.left,
since: location.since
}
})
} else {
return response.status(200).send({
location: 'Location is unknown...'
})
}
}
public async store ({ request, response }: HttpContextContract) {