Skip to content
This repository has been archived by the owner on Jul 28, 2022. It is now read-only.

Latest commit

 

History

History
50 lines (34 loc) · 731 Bytes

instructions.md

File metadata and controls

50 lines (34 loc) · 731 Bytes

Registering provider

Make sure you register the provider inside start/app.js file before making use.

const providers = [
  ...,
  '@mikield/adonis-true-traits'
]

Usage

mix(SomeClass).with(SomeTrait, AnotherTrait, ...)
Mixin a User model with MyTrait class
"use strict";

const Model = use('Model')
const MyTrait = use('App/Models/Traits/MyTrait')

class User extends Model {
 
}

module.exports = mix(User).with(MyTrait)

A exampole of MyTrait class

"use strict";

const Trait = (Model) => class extends Model {
    myFunction(){
      return "Hi from the Trait"
    }

    get myParam(){
      return "The param from Trait"
    }
}

module.exports = Trait;