Is it possible to pass parameter to Relationship Function


#1

how pass parameters Relationship !
its possible ?
Example

point (id = null) {
return this.hasOne(‘App/Models/Account/Account’, ‘point_code’, ‘code’).where(‘region_id’, id)
}


#2

@gmferreir1 Yes, you can, but not during eagerloading, since that time the function is called internally by Lucid

So following is possible

someModel.point(id).fetch()

#3

Thanks virk.
it helped a lot