Hello, how are you?

I’m a PHP programmer I came from laravel but now I’m studying NODE.JS / Adonis and there in laravel you could call functions by the “Auth” example:
Auth :: User-> Pages ()

I tried to do something similar in Adonis but I was unsuccessful did so:
auth.user.modulos () or auth.user.modulos (). fetch ()

and it didn’t work does anyone know if this is possible?



You need to define relationships first

const Model = use('Model')

class User extends Model {
  profile () {
    return this.hasOne('App/Models/Profile')

module.exports = User
const Model = use('Model')

class Profile extends Model {

module.exports = Profile

And then fetch like this

const user = await User.find(1)
const userProfile = await user.profile().fetch()
// or
const userProfile = await auth.user.profile().fetch()

sorry I forgot to send my MODEM is already like this … in javascript works using:
auth.user.modules (). fetch ()

but I want to loop it in EDGE HTML!

like this:
@each (u in auth.user.modules (). fetch ()) or
@each (u in auth.user.modules ())

but it does not work on the edge

modulos () {
return this.hasMany(‘App/Models/Modulo’)

why this does not working?

@each(u in auth.user.modulos().fetch())

                                    <li class="">

                                        <a href="index.html">

                                            <span class="pcoded-mtext">{{}} <span class="pcoded-badge label label-success">{{u.status}}</span></span>




You cant fetch data in Edge files. You should fetch it in controller and then send data to Edge

1 Like