mirror of
https://github.com/sergeyyarkov/educt-server.git
synced 2026-10-11 10:19:20 +03:00
27 lines
505 B
TypeScript
27 lines
505 B
TypeScript
import Role from 'App/Models/Role';
|
|
|
|
export default class RoleRepository {
|
|
private Role: typeof Role;
|
|
|
|
constructor() {
|
|
this.Role = Role;
|
|
}
|
|
|
|
public async getAll(params?: any) {
|
|
const { roles }: any = params || {};
|
|
const query = this.Role.query();
|
|
|
|
if (roles) {
|
|
query.whereIn('slug', roles);
|
|
}
|
|
|
|
const data = await query;
|
|
return data;
|
|
}
|
|
|
|
public async getBySlug(slug: string) {
|
|
const role = await this.Role.query().where('slug', slug);
|
|
return role;
|
|
}
|
|
}
|