1.0.31 • Published 1 year ago
@fickou/adonis-controller-helpers v1.0.31
Adonis-Controller-Helpers
Add helper on Controller for Adonis JS 5+
Table of contents
Installation
Run:
npm i --save @fickou/adonis-controller-helpers
Install provider:
node ace configure @fickou/adonis-controller-helpers
Sample Usage
Controller
In a controller
import {HttpContextContract} from "@ioc:Adonis/Core/HttpContext";
import IndexService from 'App/Services/users/Index'
import Database from "@ioc:Adonis/Lucid/Database";
export default UserController{
public index({ request, response }: HttpContextContract){
let data = await request.checkInputs();
await Database.transaction(async (trx) => {
const executor = new Index(trx);
return response.apiView(await executor.execute(data));
});
}
}
Service
In a service:
import Parameter from 'App/Models/settings/Parameter';
import ControllerHelper, from "@ioc:Adonis/Addons/ControllerHelper";
import {Service} from "@fickou/adonis-controller-helpers";
export default class Index extends Service {
async execute(payload) {
const query = Parameter.query({client: this.trx});
return ControllerHelper.searchPayload(query, payload);
}
}
// or
export default class Index extends Service {
async execute(payload) {
const query = ControllerHelper.buildQuery((this.trx || Database), (db) => db.query()
.from('parameters')
.select(['*']);
return ControllerHelper.searchDatabasePayload(query, payload);
}
}
1.0.31
1 year ago
1.0.26
1 year ago
1.0.29
1 year ago
1.0.28
1 year ago
1.0.27
1 year ago
1.0.30
1 year ago
1.0.25
1 year ago
1.0.24
1 year ago
1.0.23
1 year ago
1.0.22
1 year ago
1.0.21
1 year ago
1.0.20
1 year ago
1.0.19
1 year ago
1.0.18
1 year ago
1.0.17
1 year ago
1.0.16
2 years ago
1.0.15
2 years ago
1.0.14
2 years ago
1.0.13
2 years ago
1.0.12
2 years ago
1.0.11
2 years ago
1.0.10
2 years ago
1.0.9
2 years ago
1.0.8
2 years ago
1.0.7
2 years ago
1.0.6
2 years ago
1.0.5
2 years ago
1.0.4
2 years ago
1.0.3
2 years ago
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago