|
@@ -6,6 +6,7 @@ import { Exception } from '@adonisjs/core/build/standalone'
|
|
|
|
|
|
|
|
export default class PropertiesController {
|
|
export default class PropertiesController {
|
|
|
private paginationService = new PaginationService(Property)
|
|
private paginationService = new PaginationService(Property)
|
|
|
|
|
+
|
|
|
public async index({ request }: HttpContextContract) {
|
|
public async index({ request }: HttpContextContract) {
|
|
|
return await this.paginationService.paginate(request.all())
|
|
return await this.paginationService.paginate(request.all())
|
|
|
}
|
|
}
|
|
@@ -32,6 +33,17 @@ export default class PropertiesController {
|
|
|
return await Property.findOrFail(params.id)
|
|
return await Property.findOrFail(params.id)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public async findByName({ request }) {
|
|
|
|
|
+ console.log(request)
|
|
|
|
|
+ const data = await request.validate({
|
|
|
|
|
+ schema: schema.create({
|
|
|
|
|
+ name: schema.string()
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ console.log(data)
|
|
|
|
|
+ return await Property.findBy('name', data.name)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public async update({ request, params, bouncer }: HttpContextContract) {
|
|
public async update({ request, params, bouncer }: HttpContextContract) {
|
|
|
await bouncer.authorize('admin')
|
|
await bouncer.authorize('admin')
|
|
|
const data = await request.validate({
|
|
const data = await request.validate({
|