Add model data to another model with relation

Hi, I have two tables with two models:

  • users [id,username,password,created]
  • posts [id,user_id,message]

and for now, I want when return user data, user posts return with it. I use toArray method for json returning data for example, I want return user model data and post model data insteat of userid and postid

comment return

Use query builder. You need to do join stuff here.