i have index page with two pagination passing to. first i gave to slide to show featured items and then there is other items after that slider coming through 2nd pagination. but when i click next page. the first pagination items doesn't show but the header of that div remains. my question is what i can do to remove that whole div of slider of featured items on any other page than index page and page after ?page=1 at url. i tried to put if condition but when there is not get value at url it give me error. is there any solution that can hide whole slider div on any other page than 1 and simple index.
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>