Good morning,
I'm having a problem in a relationship between tables with Elouquent (Laravel)
I have two tables [clients / business_activities] (innoDB MYSQL)
In the client table there is a field (FK) called: _commercial_id_id In the business_activities table there is the index: id field, along with the commercial_activity (varchar) field
When I try to retrieve the customer information, I would like to see the business activity and its related customer id along with the fields.
I'm doing this in Controller:
$return = \App\Cliente::find($id)->with('atividadesComerciais')->get();
return view('clientes.show', ['data'=>$return]);
No Model:
public function atividadesComerciais()
{
return $this->belongsTo('App\AtividadesComerciais', 'atividades_comerciais_id', 'id');
}
Before I could access the information in the view by the blade so
{{ $data['razao_nome'] }}
But now it is not possible.
Where can I go wrong?