0
I’m starting at the Laravel. I have the following problem. I have three tables with relationship N:N.
- ctrl_cm_tecnicos
- ctrl_lista_tecnicos
- acl_lista_tecnicos
I have a Controller Named Technical Listingscontroller, which I am sending the data to my index. I have tested the relationship between ctrl_lista_tecnicos and ctrl_cm_tecnicos through dd($this->objTecnico->find(664)->Relcms), and the relationship occurs perfectly.
class ListagemTecnicosController extends Controller
{
private $objTecnico;
private $objCm;
private $objAcl;
public function __construct()
{
$this->objTecnico = new CtrlListaTecnico();
$this->objCm = new CtrlCmTecnico();
$this->objAcl = new AclCmTecnico();
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//dd($this->objCm->find(62)->RelTecnicos);
//dd($this->objTecnico->find(664)->RelCms);
$tecnicos=$this->objTecnico->all();
$cm=$this->objCm->all();
return view('index', compact('tecnicos', 'cm'));
}
However when I arrive at my index, I do not know how to display Regional which is in the table ctrl_cm_tecnicos.
<div class="col-12 m-auto">
<table class="table">
<thead class="thead-dark">
<tr>
<th scope="col">Id</th>
<th scope="col">Nome</th>
<th scope="col">Rg</th>
<th scope="col">CPF</th>
<th scope="col">Regional</th>
</tr>
</thead>
<tbody>
@foreach ($tecnicos as $t)
<tr>
<th scope="row">{{$t['id']}}</th>
<td>{{$t['nome']}}</td>
<td>{{$t['rg']}}</td>
<td>{{$t['cpf']}}</td>
<td>{{'Regional'}}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
The display of the other data is correct, as screen below, missing only the regional that is the cm of the table -> ctrl_cm_tecnicos.
Anyone have any ideas ? I’ve been searching for a solution for over a day but haven’t found it.
but who is regional in their table?
– novic