I'm making a query with elounque and I'm using the with () here is the code, the idea is that the field id_estado is a key forania and and that key attract more data, I make the query the problems is when I print it out error
$Solicitude = SolicitudeModel::with('id_estado')->get();
return view('Solicitude.index', [
"id_tipo" => $id_tipo,
"id_estado" => $id_estado,
"usuarios_id" => $usuarios_id,
'listmysql' => $Solicitude
]);
in the model is like this:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SolicitudeModel extends Model
{
protected $table = 'solicitudes';
protected $fillable = [
];
public function id_estado()
{
return $this->belongsTo('App\Solicitude_estado','id_estado');
}
}
and in the view I print
the query data
{
"id":1,
"descripcion":"contando de cable de energiaw",
"id_tipo":2,
"id_estado":{"id":2,"descripcion":"en procesor","created_at":"2017-11-08 23:26:09","updated_at":"2017-10-29 07:19:04"},
"created_at":"2018-03-08 21:53:12",
"updated_at":"2018-03-09 02:53:12",
"usuarios_id":1}
{
"id":2,
"descripcion":"arbol de control 2",
"id_tipo":2,
"id_estado":{"id":1,"descripcion":"pendiente","created_at":"2017-11-08 23:26:09","updated_at":"2017-10-29 07:19:04"},
"created_at":"2018-03-06 10:30:00",
"updated_at":"2017-11-09 05:34:10",
"usuarios_id":1}
and in the view to print the data I have it in the following way
@foreach($listmysql as $lists)
<?= $lists ?>
<td class="col1">{{ $lists->id }}</td>
<td class="col1">{{ $lists->descripcion }}</td>
<td class="col1">{{ $lists->id_tipo }}</td>
//linea donde sale el error
<td class="col1">{{$lists->id_estado->id }}</td>
@endforeach