{{-- Note: listing.blade.php is the page (rendered by listing() method in Front/ProductsController.php) that opens when you click on a category in the FRONT home page --}}
@extends('front.layout.layout')
@section('content')
{{-- Include the listing page sidebar (Products filters (size, color, ...)) --}}
@include('front.products.filters')
{{-- If the Search Form is not used for searching in front/layout/header.blade.php. Note that Filters will be hidden and won't work in case of using the Search Form --}}
@if (!isset($_REQUEST['search']))
{{-- Sorting Filter WITHOUT AJAX (using HTML
{{-- Sorting Filter WITH AJAX. Check ajax_products_listing.blade.php --}}
@include('front.products.ajax_products_listing')
{{-- Laravel Pagination and showing it using Bootstrap Pagination --}}
{{--
{{ $categoryProducts->links() }}
--}}
{{-- If the Search Form is not used for searching in front/layout/header.blade.php. Note that Filters will be hidden and won't work in case of using the Search Form --}}
@if (!isset($_REQUEST['search']))
{{-- Fixing the Laravel Pagination problem with the Sorting Filter where sorting gets messed up with pagination). The cause of the problem is that when you click on the pagination links like for example when you go to the second page, the URL query string parameters gets the pagination page number (e.g. 'page=2') but it loses the filter query string parameter (e.g. '&sort=desc'), so we have to always append the sorting filter query string parameter to the page number query string paramter --}}
{{-- Appending Query String Values: https://laravel.com/docs/9.x/pagination#appending-query-string-values --}}
@if (isset($_GET['sort'])) {{-- if there's a Sorting Filter used --}}