I have a table called store with fields: ID, id_master, regiao, user, atendedor, store_location. I want to display these columns and two other columns from separated tables. I want to display the sum of the columns based on the ID of the first table, meaning one table will relate to the first by ID (store.ID => ngin_agent_detail.CLIENT_ID) and the other table will relate to the first by user(store.user=>sap.created_by).
I have made these relations in first table model:
public function getNginAgentDetail()
{
return $this->hasOne(NginAgentDetail::className(),['CLIENT_ID' => 'ID']);
}
public function getSap()
{
return $this->hasOne(Sap::className(),['Criado_por' => 'user']);
}
How can i achieve this, joining three tables with sum of columns based on relations? I hope the question is clear enough or not i’ll post more details.