I am new to Laravel and need to return the client name in the View orders, currently it is only taking the ID
Classes
class Ordem extends Model
{
protected $fillable =['id','cliente_id','valor','data','problema',];
public function produtos()
{
return $this->belongsToMany(produto::class, 'ordem_id');
}
public function servicos()
{
return $this->belongsToMany(servico::class,'ordem_id');
}
}
class Cliente extends Model
{
protected $fillable = ['id','nome','cpf','endereco','telefone','email'];
protected $table = 'clientes';
public function ordens()
{
return $this->hasMany(ordem::class,'cliente_id');
}
}
class OrdemController extends Controller
{
public function listaordens()
{
$list_ordens = Ordem::all();
return view('ordem.listaordens',['ordens' => $list_ordens]);
}
}
View
@foreach($ordens as $o)
<tr>
<td> {{$o->cliente_id}} </td>
<td class="text-right"> {{($o->data)}} </td>
<td class="text-center"> {{$o->problema}} </td>
<td class="text-right"> {{$o->valor}} </td>
<td class="text-center">