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