Make sure you register the provider inside start/app.js
file before making use.
const providers = [
...,
'@mikield/adonis-true-traits'
]
mix(SomeClass).with(SomeTrait, AnotherTrait, ...)
"use strict";
const Model = use('Model')
const MyTrait = use('App/Models/Traits/MyTrait')
class User extends Model {
}
module.exports = mix(User).with(MyTrait)
"use strict";
const Trait = (Model) => class extends Model {
myFunction(){
return "Hi from the Trait"
}
get myParam(){
return "The param from Trait"
}
}
module.exports = Trait;