Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

laravel-5.2 pagination not working - undefined method stdClass::links() error

I am not able to display laravel pagination. it gives me an error undefined method stdClass::links() I have used render method but yet gives me an error undefined method stdClass::render()

here is my code

<?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>

like image 286
sujit Avatar asked Nov 27 '25 08:11

sujit


1 Answers

Please change this line @foreach($products as $products) to something like @foreach($products as $product) . I think error is Due to same variable name

like image 82
Bishnu Bhusal Avatar answered Nov 29 '25 22:11

Bishnu Bhusal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!