- second commit
This commit is contained in:
parent
4fc3bb0a01
commit
59a99ff3c8
61 changed files with 2625 additions and 1182 deletions
|
@ -4,20 +4,34 @@ import Person from 'App/Models/Person';
|
|||
|
||||
// node ace make:controller Author
|
||||
export default class AuthorsController {
|
||||
public async index({}: HttpContextContract) {
|
||||
// select * from gba.persons
|
||||
// where exists (select * from gba.documents inner join gba.link_documents_persons on "documents"."id" = "link_documents_persons"."document_id"
|
||||
// where ("link_documents_persons"."role" = 'author') and ("persons"."id" = "link_documents_persons"."person_id"));
|
||||
const authors = await Person.query()
|
||||
.whereHas('datasets', (dQuery) => {
|
||||
dQuery.wherePivot('role', 'author');
|
||||
})
|
||||
.withCount('datasets', (query) => {
|
||||
query.as('datasets_count');
|
||||
});
|
||||
|
||||
public async index({}: HttpContextContract) {
|
||||
// select * from gba.persons
|
||||
// where exists (select * from gba.documents inner join gba.link_documents_persons on "documents"."id" = "link_documents_persons"."document_id"
|
||||
// where ("link_documents_persons"."role" = 'author') and ("persons"."id" = "link_documents_persons"."person_id"));
|
||||
const authors = await Person.query()
|
||||
.whereHas('datasets', (dQuery) => {
|
||||
dQuery.wherePivot('role', 'author')
|
||||
})
|
||||
.withCount('datasets', (query) => {
|
||||
query.as('datasets_count')
|
||||
});
|
||||
|
||||
return authors;
|
||||
}
|
||||
return authors;
|
||||
}
|
||||
|
||||
public async persons({ request }: HttpContextContract) {
|
||||
const authors = Person.query().where('status', true);
|
||||
|
||||
if (request.input('filter')) {
|
||||
// users = users.whereRaw('name like %?%', [request.input('search')])
|
||||
const searchTerm = request.input('filter');
|
||||
authors
|
||||
.where('first_name', 'ilike', `%${searchTerm}%`)
|
||||
.orWhere('last_name', 'like', `%${searchTerm}%`)
|
||||
.orWhere('email', 'like', `%${searchTerm}%`);
|
||||
}
|
||||
|
||||
let persons = await authors;
|
||||
return persons;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue