3
那么这是我的问题。Laravel有很多通过只带来第一个记录
这是在我的模型公共职能
public function traerDesc(){
return $this->hasManyThrough('App\modeloDescripcionVehiculos', 'App\modeloVehiculos', 'idDescripcion', 'id', 'idVehiculo');
}
这是控制器的呼叫
$data = [
'venta' => modeloAccion::where('accion', 'venta')->with('traerVehiculo', 'traerUsuario', 'traerCliente', 'traerTransaccion', 'traerVenta', 'traerDesc')->get(),
];
return view('modulos.general.informes')->with($data);
这是我的表在刀片文件
<table class="table table-striped table-bordered table-hover" id="myTable">
<thead>
<tr>
<th class="text-center">Vehiculo vendido</th>
<th class="text-center">Precio de compra</th>
<th class="text-center">Precio de venta</th>
<th class="text-center">Ganancia %</th>
<th class="text-center">Usuario</th>
<th class="text-center">Cliente</th>
<th class="text-center">Fecha venta</th>
</tr>
</thead>
<tbody>
@foreach($venta as $ventas)
<tr class="text-center">
@foreach($ventas->traerDesc as $descripcion)
<td>{{$descripcion->marca}}</td>
@endforeach
<td>{{$ventas->traerVehiculo->precioCompra}}</td>
<td>{{$ventas->traerVehiculo->precioVenta}}</td>
<td>asd</td>
<td>{{$ventas->traerUsuario->nombre.' '.$ventas->traerUsuario->apellidoPaterno.' '.$ventas->traerUsuario->apellidoMaterno}}</td>
<td>asd</td>
<td>{{date('d-m-Y', strtotime($ventas->traerVenta->fechaVenta))}}</td>
</tr>
@endforeach
</tbody>
</table>
这是我的表安信永。如你看到的 。它有3行,其中accion = venta
和所有表中的所有人都有相同的信息。但只带来了第一行拒绝别人
和视图只有1 marca
这将是像品牌的英文显示。
希望可以把自己不够清晰。谢谢
只是一个小评论,但在未来它可能会更加便利,只是代码简单的英语一切,因为它可能会有点更容易快速理解的人那些想帮忙的人。干杯! –
你说有3条记录,并且所有三个'accions'(行动)都是'venta'(销售)? –
我想我会重新说明我的问题。 – NEOJPK