我需要你的帮助,我正在使用Laravel 6我得到这个问题后,我的html代码从无序列表到一个表,我已经检查了视图代码,但我没有看到错误
这是我的索引视图
<table class="table">
<thead class="simba-thead">
<tr>
<th>Codigo Interno / Codigo de Parte</th>
<th>Descripción</th>
<th>Percha / Bodega</th>
<th>Stock</th>
<th>Precio</th>
<th>Activo</th>
<th>Editar / Eliminar</th>
</tr>
</thead>
<tbody>
@forelse($products as $product)
<tr>
<td><a href="{{route('products.show',$product)}}">{{$product->internalCode}}</a><br>{{$product->partNumber}}</td>
<td>{{$product->description}}</td>
<td>{{$product->rack}}<br>{{$product->warehouse}}</td>
<td>1</td>
<td>{{$product->Price}}</td>
<td>{{$product->Active}}</td>
<td>edit/delete</td>
</tr>
@empty
<td>null</td>
<td>null</td>
<td>null</td>
<td>null</td>
<td>null</td>
<td>null</td>
<td>null</td>
</tr>
@endforelse
{{$products->links()}}
</tbody>
</table>我的控制器
class ProductController extends Controller
{
public function index(){
return view('products.index',[
'products'=>Product::latest()->paginate()
]);
}
public function show(Product $product){
return view('products.show',[
'product'=>$product
]);
}
}我的路线
Route::resource('products','ProductController')->names('products');发布于 2021-06-27 11:32:28
问题是Laravel在默认情况下使用字段名称' id‘来标识表格中的主键。我解决了它,将这一行添加到我的模型中。
protected $primaryKey = 'productId';https://stackoverflow.com/questions/68147389
复制相似问题