Create pivot model for user-role mapping


I’m using adonis acl for user - roles - permission mapping. In this structure the mapping between roles - permissions is belongsToMany mapping and a pivot table is generated to store mapping values and i can define pivot model to have any control over the pivot table and i can define hooks, getters etc. by defining

cars () {
return this

But in User - Roles and User - Permissions mapping it is done by traits in the user modal.

class User extends Model {

static get traits () {
return [


Here there is no belongsToMany mapping but join tables named role_users and permission_users are created. Now i want to create pivot model for these mapping tables role_users and permission_users to define a hook or getters/setters but i’m not able to do this. Kindly help me to create a pivot model for user-role, user-permission mapping.

Thanks in advance.