0
I have 3 tables, processos
, empresas
and processos_empresas
.
table structure:
processos:
- id
empresas:
- id
- nome_empresa
processos_empresas:
- processo_id
- empresa_id
Brief explanation of how they relate:
A process can have multiple companies, and these process companies are saved in the table processos_empresas
with the process id and the loan.
Currently within the process model there is a method called businesses that brings all companies registered in the table processos_empresas
with the relationship hasMany
, example:
namespace App;
use Illuminate\Database\Eloquent\Model;
class Processo extends Model {
function empresas () {
return $this->hasMany('App\ProcessoEmpresas');
}
}
What I need to do is, inside the process model, also pull table data empresa
through the table processos_empresas
as it is already being done, basically I also need the column company name
I found in the documentation the hasManyTrough, but I did not succeed in implementing
Posta a Migrations
– Romulo Sousa
Pass the model like this on the doc
– Romulo Sousa
I didn’t get it, I posted the basic structure up there
– Thiago
– Romulo Sousa
It’s more than that, it would be a relationship within processes > processes_companies > companies
– Thiago