gpt4 book ai didi

php - laravel-5.2 分页不起作用 - 未定义方法 stdClass::links() 错误

转载 作者:行者123 更新时间:2023-12-05 04:13:20 25 4
gpt4 key购买 nike

我无法显示 Laravel 分页。它给了我一个错误 undefined method stdClass::links() 我已经使用了 render 方法但是却给我一个错误 undefined method stdClass::render()

这是我的代码

<?php $products = DB::table('products')->where('category_id',$category-> id)->paginate(4); ?>



@foreach($products as $products)
<li class="product-item col-md-3 col-sm-6 col-xs-12">
<div class="product-inner">
<div class="thumb has-second-image">
<a href="#">
@if(empty($products-> medium_product_image))
{{ HTML::image('images/no-image.gif',$products-> product_name) }}
@else
{{ HTML::image($products-> medium_product_image,$products-> product_name) }}
@endif
</a>
</div>
<div class="info">
<h3 class="product-name short"><a href="#">{{ $products-> product_name }}</a></h3>
<span class="price">{{ $products-> product_price }}</span>
<del>{{ $products-> product_old_price }}</del>
</div>
</div>
</li>
@endforeach



<nav class="pagination navigation">
<ul class="page-numbers">
<li>{!! $products-> links() !!}</li>
</ul>

最佳答案

请将此行 @foreach($products as $products) 更改为类似 @foreach($products as $product) 的内容。我认为错误是由于相同的变量名

关于php - laravel-5.2 分页不起作用 - 未定义方法 stdClass::links() 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38077051/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com