laravel:单击第二分页的下一页时如何删除第一分页

时间:2019-12-28 17:19:44

标签: php html laravel pagination

我有两个分页传递给的索引页。首先,我给幻灯片显示了特色项目,然后该滑块经过第二个分页之后还有其他项目。但是当我单击下一页时。第一个分页项未显示,但该div的标题保留。我的问题是我该怎么做才能删除除索引页面和URL的?page = 1之后的页面以外的任何其他页面上特色项目滑块的整个div。我试图把如果条件,但当没有获得价值在URL它给我错误。是否有任何解决方案可以在除1和简单索引之外的任何其他页面上隐藏整个滑块div。

    class IndexController extends Controller
    {
        public function Index(){
            //Get all Products 
            $allProducts = DB::table('categories')
                ->join('products','products.category_id','=', 'categories.id')
                ->where('categories.status','=','1')->where('products.status','=','1')->paginate(9);


            // Get featured products
            $featuredProducts = DB::table('categories')
                ->join('products','products.category_id','=', 'categories.id')
                ->where('categories.status','=','1')->where('products.status','=','1')->where('feature_item',1)->paginate(25);


            //Get all Categories and sub Categories
            $categories = Category::with('categories')->where(['parent_id'=>0])->get();

            $banners = Banner::where('status','1')->get();

            return view('index')->with(compact('featuredProducts','allProducts','categories','banners'));

        }
    }

   <section>
    <div class="container">
        <div class="row">
            <div class="col-sm-3">
                @include('layouts.frontLayout.front_sidebar')
            </div>
              <div class="col-sm-9 padding-right">
                 <div class="features_items">
                    <h2 class="title text-center">Featured Items</h2>
                    <div id="recommended-item-carousel" class="carousel slide" data-ride="carousel">
                        <div class="carousel-inner">
                            <?php $count=1; ?> 
                            @foreach($featuredProducts->chunk(3) as $chunk)
                                <div <?php if($count==1){ ?> class="item active" <?php }else{ ?> class="item" <?php } ?>>
                                    @foreach($chunk as $item)   
                                        <div class="col-sm-4">
                                            <div class="product-image-wrapper">
                                                <div class="single-products">
                                                    <div class="productinfo text-center">
                                                        <img style="width:200px;" src="{{ asset('images/backend_images/products/small/'.$item->image) }}" alt="" />
                                                        <h2>$ {{ $item->price }} </h2>
                                                        <p> {{ $item->product_name }}</p>
                                                        <a href="{{ url('/product/'.$item->id) }}">
                                                            <button type="button" class="btn btn-default add-to-cart"><i class="fa fa-shopping-cart"></i>Add to cart</button>
                                                        </a>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    @endforeach
                                </div>
                            <?php $count++; ?>
                            @endforeach
                        </div>
                         <a class="left recommended-item-control" href="#recommended-item-carousel" data-slide="prev">
                            <i class="fa fa-angle-left"></i>
                          </a>
                          <a class="right recommended-item-control" href="#recommended-item-carousel" data-slide="next">
                            <i class="fa fa-angle-right"></i>
                          </a>          
                    </div>
                 </div>
              </div>
        </div>
    </div>
    <div class="container">
        <div class="row">
            <div class="col-sm-3">

            </div>
            <div class="col-sm-9 padding-right">
                <div class="features_items"><!--features_items-->
                    <h2 class="title text-center">All Items</h2>
                    @foreach($allProducts as $product)
                    <div class="col-sm-4">
                        <a class="product-image-wrapper" href="{{ url('product/'.$product->id) }}">
                            <div class="single-products">
                                    <div class="productinfo text-center">
                                        <img src="{{ asset('images/backend_images/products/small/'.$product->image) }}" alt="" />
                                        <h2>C$ {{ $product->price }}</h2>
                                        <p>{{ $product->product_name }}</p>
                                        <a href="{{ url('product/'.$product->id) }}" class="btn btn-default add-to-cart"><i class="fa fa-shopping-cart"></i>Add to cart</a>
                                    </div>
                            </div>
                        </a>
                    </div>
                    @endforeach
                </div><!--features_items--> 
                <div align="center">{{ $allProducts->links() }}</div>
            </div>
        </div>
    </div>
</section>

1 个答案:

答案 0 :(得分:0)

您可以使用__func__来检查查询参数。

request()->getQueryString()