Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

morkslagen's avatar

MethodNotAllowedHttpException after i use render function

i use render for pagination after i used i get this error Whoops, looks like something went wrong.

1/1 MethodNotAllowedHttpException in RouteCollection.php line 218: this my routes Route::post('Search/{menu1}/{menu2}/{menu3}/page','SearchController@search_test'); Route::get('Search/{menu1}/{menu2}/{menu3}','SearchController@search1'); this is my controller public function search_test($menu1, $menu2, $menu3, Request $request) { $test=1; if($request->has('product_filter')) { $test=$request->get('product_filter');

                }
                if($test==0){
                    if($request->has('filter_id'))
                    {
                        $filter_id=$request->get('filter_id');
                        $array1=explode(',',$filter_id);
                        $id=array();
                        $i=0;
                        foreach($array1 as $key=>$value)
                        {
                            $e=explode('-',$value);
                            if(array_key_exists(1,$e))
                            {
                                $id[$e[1]][$i]=$e[0];
                                $i++;
                            }
                        }
                        $check=array();
                        $product_id='';
                        foreach($id as $key2=>$value2)
                        {
                            $row=DB::table('filter_product')->whereIn('filter_id',$value2)->get();
                            $i=0;
                            foreach($row as $key3=>$value3)
                            {
                                $check[$key2][$i]=$value3->product_id;
                                $i++;
                            }
                        }
                        if(sizeof($check)>1)
                        {
                            $product_id=call_user_func_array('array_intersect',$check);
                        }
                        else
                        {
                            foreach($check as $key=>$value)
                            {
                                foreach($value as $key1=>$value1)
                                {
                                    $product_id[$key1]=$value1;
                                }
                            }
                        }
                        if($request->has('product_action'))
                        {

                            $product_action=$request->get('product_action');
                        }
                        else
                        {
                            $product_action=0;
                        }

                        $product_order=$request->has('product_order') ? $request->get('product_order') : 1;
                        $product_type=$request->has('type_product') ? $request->get('type_product') : 1;
                        $order=array();
                        $order[1]='id';
                        $order[2]='View';
                        $order[3]='price';

                        $type=array();
                        $type[1]='DESC';
                        $type[2]='ASC';
                        if($request->has('price'))
                        {
                            if($request->has('search'))
                            {
                                $txt=$request->get('search');

                                if($product_action==0)
                                {
                                    $price=explode(',',$request->get('price'));
                                    $product=Product::whereIn('id',$product_id)
                                        ->where('title','LIKE','%'.$txt.'%')
                                        ->where('price','>=',$price[0])
                                        ->where('price','<=',$price[1])
                                        ->orWhere('code','LIKE','%'.$txt.'%')
                                        ->where('price','>=',$price[0])
                                        ->where('price','<=',$price[1])
                                        ->orderBy($order[$product_order],$type[$product_type])->paginate(10);
                                }
                                else
                                {
                                    $price=explode(',',$request->get('price'));
                                    $product=Product::whereIn('id',$product_id)
                                        ->where('product_state',$product_action)
                                        ->where('code','LIKE','%'.$txt.'%')
                                        ->where('price','>=',$price[0])
                                        ->where('price','<=',$price[1])
                                        ->orwhere('title','LIKE','%'.$txt.'%')
                                        ->where('product_state',$product_action)
                                        ->where('price','>=',$price[0])
                                        ->where('price','<=',$price[1])
                                        ->orderBy($order[$product_order],$type[$product_type])->paginate(10);
                                }
                            }
                            else
                            {
                                if($product_action==0)
                                {
                                    $price=explode(',',$request->get('price'));
                                    $product=Product::whereIn('id',$product_id)
                                        ->where('price','>=',$price[0])
                                        ->where('price','<=',$price[1])
                                        ->orderBy($order[$product_order],$type[$product_type])->paginate(10);
                                }
                                else
                                {
                                    $price=explode(',',$request->get('price'));
                                    $product=Product::whereIn('id',$product_id)
                                        ->where('product_state',$product_action)
                                        ->where('price','>=',$price[0])
                                        ->where('price','<=',$price[1])
                                        ->orderBy($order[$product_order],$type[$product_type])->paginate(10);
                                }
                            }


                        }
                        else
                        {
                            if($product_action==0)
                            {
                                $product=Product::whereIn('id',$product_id)
                                    ->orderBy($order[$product_order],$type[$product_type])->paginate(10);
                            }
                            else
                            {
                                $product=Product::whereIn('id',$product_id)
                                    ->where('product_state',$product_action)
                                    ->orderBy($order[$product_order],$type[$product_type])->paginate(10);
                            }
                        }
                        return View('site.filter_ajax',['product'=>$product]);
                    }


                }

                elseif($test==1){

                    $id3=$request->get('cat_id');
                    $Cat3=Category::where('id',$id3)->first();
                    //  $menu3=$Cat3->ename;
                    $id2=$Cat3->parent_id;
                    $Cat2=Category::where('id',$id2)->first();
                    //   $menu2=$Cat2->enam;
                    $id1=$Cat2->parent_id;
                    $Cat1=Category::where('id',$id1)->first();
                    //  $menu1=$Cat1->ename;
                    $Category=\App\Category::where('parent_id',0)->get();
                    $right_filter=$this->right_filter($Cat1->id,$Cat2->id,$Cat3->id);
                    $top_filter=$this->top_filter($Cat1->id,$Cat2->id,$Cat3->id);
                    // $search=$request->has('search');

                    $order=array();
                    $order[1]='id';
                    $order[2]='View';
                    $order[3]='price';
                    $type=array();
                    $type[1]='DESC';
                    $type[2]='ASC';
                    $product_id=$request->get('cat_id');
                    if($request->has('product_action'))
                    {

                        $product_action=$request->get('product_action');
                    }
                    else
                    {
                        $product_action=0;
                    }

                    $product_order=$request->has('product_order') ? $request->get('product_order') : 1;
                    $product_type=$request->has('type_product') ? $request->get('type_product') : 1;
                    $order=array();
                    $order[1]='id';
                    $order[2]='View';
                    $order[3]='price';

                    $type=array();
                    $type[1]='DESC';
                    $type[2]='ASC';
                    if($request->has('price'))
                    {
                        if($request->has('search'))
                        {
                            $txt=$request->get('search');

                            if($product_action==0)
                            {
                                $price=explode(',',$request->get('price'));
                                $product=Product::where('cat',$product_id)
                                    ->where('title','LIKE','%'.$txt.'%')
                                    ->where('price','>=',$price[0])
                                    ->where('price','<=',$price[1])
                                    ->orWhere('code','LIKE','%'.$txt.'%')
                                    ->where('price','>=',$price[0])
                                    ->where('price','<=',$price[1])
                                    ->orderBy($order[$product_order],$type[$product_type])->paginate(10);
                            }
                            else
                            {
                                $price=explode(',',$request->get('price'));
                                $product=Product::where('cat',$product_id)
                                    ->where('product_state',$product_action)
                                    ->where('code','LIKE','%'.$txt.'%')
                                    ->where('price','>=',$price[0])
                                    ->where('price','<=',$price[1])
                                    ->orwhere('title','LIKE','%'.$txt.'%')
                                    ->where('product_state',$product_action)
                                    ->where('price','>=',$price[0])
                                    ->where('price','<=',$price[1])
                                    ->orderBy($order[$product_order],$type[$product_type])->paginate(10);
                            }
                        }
                        else
                        {
                            if($product_action==0)
                            {
                                $price=explode(',',$request->get('price'));
                                $product=Product::where('cat',$product_id)
                                    ->where('price','>=',$price[0])
                                    ->where('price','<=',$price[1])
                                    ->orderBy($order[$product_order],$type[$product_type])->paginate(10);
                            }
                            else
                            {
                                $price=explode(',',$request->get('price'));
                                $product=Product::where('cat',$product_id)
                                    ->where('product_state',$product_action)
                                    ->where('price','>=',$price[0])
                                    ->where('price','<=',$price[1])
                                    ->orderBy($order[$product_order],$type[$product_type])->paginate(10);
                            }
                        }


                    }
                    else
                    {
                        if($product_action==0)
                        {
                            $product=Product::where('cat',$product_id)
                                ->orderBy($order[$product_order],$type[$product_type])->paginate(10);
                        }
                        else
                        {
                            $product=Product::where('cat',$product_id)
                                ->where('product_state',$product_action)
                                ->orderBy($order[$product_order],$type[$product_type])->paginate(10);
                        }
                    }
                    return View('site.filter_ajax',['product'=>$product]);

                    // return View('site.filter_ajax',['product'=>$product,'right_filter'=>$right_filter,'top_filter'=>$top_filter,'Category'=>$Category,'cat_name'=>$Cat3->name,'cat_id'=>$Cat3->id,'Cat1'=>$menu1,'Cat2'=>$menu2,'Cat3'=>$menu3,'test'=>$test]);



                }




}

public function search1($menu1,$menu2,$menu3, Request $request) { //$Test=$request->url(); $Cat1=Category::where('ename',$menu1)->first(); if($Cat1) { $Cat2=Category::where('ename',$menu2)->first(); if($Cat2 && $Cat2->parent_id==$Cat1->id) { $Cat3=Category::where('ename',$menu3)->first(); if($Cat3 && $Cat3->parent_id==$Cat2->id) { $Category=\App\Category::where('parent_id',0)->get(); $product=Product::where('cat',$Cat3->id)->orderBy('id','DESC')->paginate(5); $right_filter=$this->right_filter($Cat1->id,$Cat2->id,$Cat3->id); $top_filter=$this->top_filter($Cat1->id,$Cat2->id,$Cat3->id); $currentPage = Session::get('url'); $data = array();

                //Get current page form url e.g. &page=6

                $results=$product;
                //Create a new Laravel collection from the array data
                $collection = new Collection($results);

                //Define how many items we want to be visible in each page
                $per_page = 5;

                //Slice the collection to get the items to display in current page
                $currentPageResults = $collection->slice(($currentPage-1) * $per_page, $per_page)->all();

                //Create our paginator and add it to the data array
                $data['results'] = new LengthAwarePaginator($currentPageResults, count($collection), $per_page);

                //Set base url for pagination links to follow e.g custom/url?page=6
                $data['results']->setPath($request->url());


                return View('site.search1',['product'=>$product,'right_filter'=>$right_filter,'top_filter'=>$top_filter,'Category'=>$Category,'cat_name'=>$Cat3->name,'cat_id'=>$Cat3->id,'cat_id'=>$Cat3->id,'Cat1'=>$menu1,'Cat2'=>$menu2,'Cat3'=>$menu3]);


            }
            else
            {
                return view('404');
            }
        }
        else
        {
            return view('404');
        }
    }
    else
    {
        return view('404');
    }
}

this is my filter_ajax blad @if(sizeof($product)>0)

@foreach($product as $key=>$value)
    <?$compares_id=$value->id;?>


    <div id="product" class="products-tbl">
        <div class="row" style="border:1px solid #e6e6e6;margin: 0 0 20px 0">

            <a href="{{ url('Product').'/'.$value->code_url.'/'.$value->title_url }}">
                @if($value->get_img!=null)
                    <img class="responsive-img" src="{{ url('').'/'.$value->get_img->url }}">
                @else
                    <div class="col s12 m12 l12" style="background: #f7f7f7;margin: 0;padding: 0"><img class="responsive-img" style="" src="{{ url('images/no-image.png') }}" alt="no-image"></div>
                @endif
            </a>

            <a href="{{ url('Product').'/'.$value->code_url.'/'.$value->title_url }}"><div class="etc navy-blue padding-r-l" style="font-size: .89rem;margin-bottom: 10px"><?= $value['title']; ?></div></a>


            @if(!empty($value->price))
                <div class="row" style="margin: 0 0 20px 0;">
                    @if(!empty($value->discounts))
                        <div style="color:red;padding-left:10px;text-decoration: line-through;font-size:14px;height:20px;float: left">
                            <?= number_format($value['price']) ?> تومان</div>
                    @else
                        <div style="height:20px;float: left"></div>
                    @endif
                    <div style="float:right;font-size:16px;color:#004358;padding-right:10px;"><?php $price=$value['price']-$value['discounts']; echo number_format($price)  ?> تومان</div>
                </div>
                <div style="margin: 0;width: 100%;display: inline">
                    <a class="products-cart-btn" href="<?= url('Product/').'/'.$value['code_url'].'/'.$value['title_url'] ?>" >خرید&nbsp;&nbsp;&nbsp;&nbsp;<i class="fa fa-shopping-cart" style="color:#fff" aria-hidden="true"></i></a>
                    <a class="products-compare-btn" href="#" ><i class="fa fa-balance-scale" aria-hidden="true"></i></a>
                </div>
            @endif
        </div>
    </div>
@endforeach
<div class="row">
    <div class="col s12 m12 l12 center-align">


        {!! $product->render() !!}
        {!! URL::current() !!}


    </div>



</div>

@else موردی در بین محصولات یافت نشد. @endif

this the second

@extends('layouts.site') @section('title') محصولات | @endsection @section('content')

<div class="container rtl">
    <div class="row bottom0">
        <div class="col s12 m12 l12">
            <div class="card-panel" style="background: white;direction: rtl;padding-top: 8px;font-size: .8rem">
                <div class="col s12 right-align">
                    <a href="<?= url('') ?>" class="navy-blue">صفحه اصلی</a>&nbsp;&nbsp;&nbsp;<i class="fa fa-angle-left" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;
                    <a href="#" class="navy-blue">گروه ها</a>&nbsp;&nbsp;&nbsp;<i class="fa fa-angle-left" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;
                    <a class="navy-blue"><?= $cat_name ?></a>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="container rtl">
    <div class="row">
        <div class="col s12 m12 l12">
            <div class="card-panel">
                <?php

                $p=DB::table('product')->where('cat',$cat_id)->orderBy('price','DESC')->first();
                if($p)
                {
                    $product_price=$p->price;
                }
                else
                {
                    $product_price=0;
                }
                ?>
                <div class="row bottom0 navy-blue">
                    <div class="col l2 hide-on-med-and-down">

                        <p style="font-weight:bold;direction:rtl">بر اساس قیمت</p>
                        <div id="slider" style="width:90%;margin-top:20px;margin-left:7%;margin-bottom:5px;"></div>
                        <div class="row">
                            <span id="price_1" class="left">0 تومان</span>
                            <span id="price_2" class="right"><?= $product_price; ?> تومان</span>
                        </div>
                        <div class="divider"></div>

                        @if(sizeof($right_filter)>0)

                            <?php $a=1; ?>
                            @foreach($right_filter as $key=>$value)

                                <p style="direction: rtl;font-weight:bold"><?= $value['name']; ?></p>

                                <div class="filter-items" style="max-height: 310px; overflow-y: auto">

                                    <?php
                                    $child_filter=$value->get_child_filter;
                                    ?>
                                    @if(sizeof($child_filter)>0)

                                        @foreach($child_filter as $key1=>$value1)

                                            @if($value->filed==1)

                                                <?php
                                                $color=explode('-',$value1->name);
                                                ?>

                                                <p class="clearfix">
                                                <div style="float:right;width:10px;height:18px;margin-left:5px;background: #<?= $color[1] ?>"></div><input id="filter_{{ $value1->id }}" class="filter_product" value="{{ $value1->id }}-{{ $a }}" onclick="set_filter(<?=$cat_id ?>)" type="checkbox"><label class="navy-blue padding-r-l" for="filter_{{ $value1->id }}">{{ $color[0] }}</label>
                                                </p>
                                            @else

                                                <p class="clearfix">
                                                    <input id="filter_{{ $value1->id }}" class="filter_product" value="{{ $value1->id }}-{{ $a }}" onclick="set_filter(<?=$cat_id?>)" type="checkbox"><label class="navy-blue padding-r-l" for="filter_{{ $value1->id }}">{{ $value1->name }}</label>
                                                </p>

                                            @endif


                                        @endforeach

                                    @endif

                                </div>
                                <div class="divider"></div>
                                <?php $a++; ?>
                            @endforeach

                        @endif
                    </div>
                    <div class="col s12 m12 l10">
                        <div id="compare" class="row">
                            @if(sizeof(Session::get('compare'))>0)
                                <div class="col l2-5 m2-5 m12">
                                    <a class="waves-light btn btn-shop" style="margin-bottom: 15px" href="{{ url('Item_compare') }}">نتیجه مقایسه</a>
                                    <button class="waves-light btn btn-shop">حذف همه</button>
                                </div>
                                @foreach(Session::get('compare') as $key=>$value)
                                    <div class="col l2-5 m2-5 m12">
                                        <?php
                                        $product_id=$key;
                                        $img=DB::table('images')->where('product_id',$product_id)->first();
                                        $Product=\App\Product::get_product_data($product_id);
                                        if($img)
                                        {
                                            $img=url('').'/'.$img->url;
                                        }
                                        else
                                        {
                                            $img='';
                                        }
                                        ?>
                                        <div style="float:right;margin-top:60px;margin-bottom:20px;"><img src="<?= $img ?>" style="width: 110px;margin-right:5px;"></div>
                                        <i onclick="del_order('<?= $product_id ?>')" class="fa fa-times-circle-o" aria-hidden="true"></i>
                                    </div>
                                @endforeach
                            @endif
                        </div>

                    <!--      <div style="width:100%;float:right">
                            @if(sizeof($top_filter)>0)
                        <?php $j=$a ?>
                        @foreach($top_filter as $key=>$value)


                            <div id="select_filter_<?= $key ?>" style="float:right">

                                        <div class="li_filter">
                                            <span><?= $value->name ?></span>

                                            <div id="a">

                                                <ul class="filter">
                                                    <?php
                            $child_filter=$value->get_child_filter;
                            ?>
                            @if(sizeof($child_filter)>0)

                                @foreach($child_filter as $key1=>$value1)

                                    <li onclick="set_filters(<?= $value1->id; ?>,<?= $key ?>,'<?= $value1->name ?>')">
                                                                <input name="product_filter_<?= $key ?>" class="filter_product" id="left_filter_<?= $value1->id ?>" type="hidden" value="<?= $value1->id.'-'.$j; ?>">
                                                                <?= $value1['name']; ?></li>

                                                        @endforeach

                            @endif
                                    </ul>

                                </div>

                            </div>

                        </div>


                        <?php $j++ ?>
                        @endforeach

                    @endif
                            </div>
                            -->

                        <div class="row">
                            <div class="col m5 l5 hide-on-small-only">
                                <form class="search-nav">
                                    <input class="right" name="search_box" id="search_box" type="text" placeholder="محصولی جستجو کنید ..." id="search1">
                                    <button class="search-btn left" onclick="search(<?= $cat_id; ?>)"><i class="material-icons">search</i></button>
                                </form>
                            </div>

                            <div class="col s12 m7 l7">
                                <div style="display: inline-block;float:right;width: 100%">
                                    <label class="navy-blue products-top">ترتیب براساس</label>
                                    <select class="browser-default products-top" onchange="set_order(<?= $cat_id; ?>)" id="order" style="width: 25%">
                                        <option value="1">جدیدترین</option>
                                        <option value="2">پر بازدیدترین</option>
                                        <option value="3">قیمت</option>
                                    </select>

                                    <select class="browser-default products-top" id="type" onchange="set_order(<?= $cat_id; ?>)" style="width: 20%">
                                        <option value="1">صعودی</option>
                                        <option value="2">نزولی</option>
                                    </select>

                                    <label class="navy-blue products-top">تعداد نمایش</label>
                                    <select class="browser-default products-top" id="total_product" onchange="set_number_product()" style="width: 12%">
                                        <option value="1">12</option>
                                        <option value="2">24</option>
                                        <option value="3">36</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div id="products" class="row">

                            @if(sizeof($product)>0)

                                @foreach($product as $key=>$value)
                                    <?$compares_id=$value->id;?>
                                    <div id="product" class="products-tbl">
                                        <div class="row hoverable" style="border:1px solid #e6e6e6;margin: 0 0 20px 0;border-radius: 2px">
                                            <a href="{{ url('Product').'/'.$value->code_url.'/'.$value->title_url }}">
                                                @if($value->get_img!=null)
                                                    <img class="responsive-img" src="{{ url('').'/'.$value->get_img->url }}">
                                                @else
                                                    <div class="col s12 m12 l12" style="background: #f7f7f7;margin: 0;padding: 0"><img class="responsive-img" style="" src="{{ url('images/no-image.png') }}" alt="no-image"></div>
                                                @endif
                                            </a>

                                            <a href="{{ url('Product').'/'.$value->code_url.'/'.$value->title_url }}"><div class="etc navy-blue padding-r-l" style="font-size: .89rem;margin-bottom: 10px"><?= $value['title']; ?></div></a>

                                            <div class="row" style="margin: 0 0 20px 0;min-height: 30px">
                                                @if(!empty($value->price))
                                                    @if(!empty($value->discounts))
                                                        <div style="color:red;padding-left:10px;text-decoration: line-through;font-size:14px;height:20px;float: left">
                                                            <?= number_format($value['price']) ?> تومان</div>
                                                    @else
                                                        <div style="height:20px;float: left"></div>
                                                    @endif
                                                    <div style="float:right;font-size:16px;color:#004358;padding-right:10px;"><?php $price=$value['price']-$value['discounts']; echo number_format($price)  ?> تومان</div>
                                                @endif
                                            </div>
                                            <div style="margin: 0;width: 100%;display: inline">
                                                <a class="products-cart-btn" href="<?= url('Product/').'/'.$value['code_url'].'/'.$value['title_url'] ?>" >خرید&nbsp;&nbsp;&nbsp;&nbsp;<i class="fa fa-shopping-cart" style="color:#fff" aria-hidden="true"></i></a>
                                                <button class="products-compare-btn" id="compare_{{ $value->id }}" onclick="set_compare(<?=$compares_id?>,<?= $value->id ?>)" type="button"><i class="fa fa-balance-scale" aria-hidden="true"></i></button>
                                            </div>
                                        </div>
                                    </div>
                                @endforeach
                                <div class="row">
                                    <?$link_limit=10?>
                                    <div class=" pagination col s12 m12 l12 center-align navy-blue">
                                        {!! $product->render() !!}

{!! URL::current() !!}

                                    </div>
                                </div>
                            @else
                                <div style="margin-right: 30px">موردی در بین محصولات یافت نشد.</div>
                            @endif
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

@endsection

@section('footer') var product_action=0; var order_product=1; var type_product=1; var values=0; $('.toggle-light').toggles({ width:40, height:15, text:{on:'',off:''}

    });

    var slider = document.getElementById('slider');


    noUiSlider.create(slider, {

        start: [0,<?= $product_price ?>],
        connect: true,
        range: {
            'min': 0,
            'max':<?= $product_price ?>
        }

    });
    set_filter=function(cat_id)
    {
        alert(1);

        var cat_id=cat_id;
        var checkbox=document.getElementsByClassName('filter_product');
        var search_text=document.getElementById('search_box').value;
        var array=new Array();
        var j=0;
        for(var i=0;i<checkbox.length;i++)
        {
            if(checkbox[i].checked)
            {
                array[j]=checkbox[i].value;
                j++;
            }

        }
        var product_filter=0;

        if(array.length>0){

            alert(product_filter);
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }});
            $.ajax({

               url:'<?= url('Search/'.$Cat1.'/'.$Cat2.'/'.$Cat3.'/page') ?>',
                type:"POST",

                data:'filter_id='+array+'&product_action='+product_action+'&price='+values+'&cat_id='+cat_id+ '&search=' + search_text+'&product_filter='+product_filter,
                success:function(data)
                {
                    $("#products").html(data);
                }
            });
        }
        else{

            product_filter=1;
            alert(product_filter);


            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }});
            $.ajax({

             url:'<?= url('Search/'.$Cat1.'/'.$Cat2.'/'.$Cat3.'/page') ?>',
                type:"POST",
                data:'filter_id='+array+'&product_action='+product_action+'&price='+values+'&cat_id='+cat_id+ '&search=' + search_text+'&product_filter='+product_filter,
                success:function(data)
                {
                    alert(data);
                    $("#products").html(data);
                }
            });
        }

    };

    $('.toggle-light').on('toggle',function(e,action)
    {
        alert(2);

        var cat_id = "<?php echo $cat_id ?>";


        if(action)
        {

            product_action=1;

        }
        else
        {
            product_action=0;
        }
        var checkbox=document.getElementsByClassName('filter_product');
        var search_text=document.getElementById('search_box').value;
        var array=new Array();
        var j=0;
        for(var i=0;i<checkbox.length;i++)
        {
            if(checkbox[i].checked)
            {
                array[j]=checkbox[i].value;
                j++;
            }

        }
        var product_filter=0;

        if(array.length>0){
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }});
            $.ajax({

             url:'<?= url('Search/'.$Cat1.'/'.$Cat2.'/'.$Cat3.'/page') ?>',
                type:"POST",
                data:'filter_id='+array+'&product_action='+product_action+'&price='+values+ '&search=' + search_text+'&product_filter='+product_filter,
                success:function(data)
                {
                    $("#products").html(data);
                }
            });


        }
        else{

            product_filter=1;
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }});
            $.ajax({

             url:'<?= url('Search/'.$Cat1.'/'.$Cat2.'/'.$Cat3.'/page') ?>',
                type:"POST",
                data:'filter_id='+array+'&product_action='+product_action+'&price='+values+'&cat_id='+cat_id+ '&search=' + search_text+'&product_filter='+product_filter,
                success:function(data)
                {
                    $("#products").html(data);
                }

            });
        }

    });
    set_order=function(cat_id )
    {
        alert(3);
        var cat_id=cat_id;
        var value=document.getElementById('order').value;
        var type=document.getElementById('type').value;
        alert(value);alert(type);
        order_product=value;
        type_product=type
        var checkbox=document.getElementsByClassName('filter_product');
        var search_text=document.getElementById('search_box').value;
        var array=new Array();
        var j=0;
        for(var i=0;i<checkbox.length;i++)
        {
            if(checkbox[i].checked)
            {
                array[j]=checkbox[i].value;
                j++;
            }

        }
        var product_filter=0;

        if(array.length>0){
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }});
            $.ajax({

             url:'<?= url('Search/'.$Cat1.'/'.$Cat2.'/'.$Cat3.'/page') ?>',
                type:"POST",
                data:'filter_id='+array+'&product_action='+product_action+'&product_order='+value+'&type_product='+type+'&price='+values+ '&search=' + search_text+'&product_filter='+product_filter,
                success:function(data)
                {
                    $("#products").html(data);
                }
            });
        }
        else{

            product_filter=1;

            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });
            $.ajax({

             url:'<?= url('Search/'.$Cat1.'/'.$Cat2.'/'.$Cat3.'/page') ?>',
                type: "POST",
                data:'filter_id='+array+'&product_action='+product_action+'&product_order='+value+'&type_product='+type+'&price='+values+'&cat_id='+cat_id+ '&search=' + search_text+'&product_filter='+product_filter,
                success: function (data) {
                    $("#products").html(data);
                }
            });

        }

    };
    $('.li_filter').hover(
        function()
        {
            $(this).find('div').show();
            this.style.background='#ffffff';
        },
        function()
        {
            $(this).find('div').hide();
            this.style.background='#f4f3f8';
        }
    );

    del_filter=function(id)
    {
        alert(4);
        var cat_id="<? echo $cat_id ?>"
        document.getElementById('left_filter_'+id).checked=false;

        $("#left_filters_"+id).remove();
        var checkbox=document.getElementsByClassName('filter_product');
        var search_text=document.getElementById('search_box').value;
        var array=new Array();
        var j=0;
        for(var i=0;i<checkbox.length;i++)
        {
            if(checkbox[i].checked)
            {
                array[j]=checkbox[i].value;
                j++;
            }

        }
        var product_filter=0;

        if(array.length>0){
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }});
            $.ajax({

             url:'<?= url('Search/'.$Cat1.'/'.$Cat2.'/'.$Cat3.'/page') ?>',
                type:"POST",
                data:'filter_id='+array+'&product_action='+product_action+'&price='+values+ '&search=' + search_text+'&product_filter='+product_filter,
                success:function(data)
                {
                    $("#products").html(data);
                }
            });
        }
        else{

            product_filter=1;
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });
            $.ajax({

             url:'<?= url('Search/'.$Cat1.'/'.$Cat2.'/'.$Cat3.'/page') ?>',
                type: "POST",
                data:'filter_id='+array+'&product_action='+product_action+'&price='+values+'&cat_id='+cat_id+ '&search=' + search_text+'&product_filter='+product_filter,
                success: function (data) {
                    $("#products").html(data);
                }
            });

        }


    };
    var skipValues = [
        document.getElementById('price_1'),
        document.getElementById('price_2')
    ];
    slider.noUiSlider.on('update', function( values, handle )
    {

        var cat_id="<? echo $cat_id?>";
        window.values=values;
        var string= values[handle];
        var str=string.split('.');
        skipValues[handle].innerHTML =str[0]+'تومان';

        var checkbox=document.getElementsByClassName('filter_product');
        var search_text=document.getElementById('search_box').value;
        var array=new Array();
        var j=0;
        for(var i=0;i<checkbox.length;i++)
        {
            if(checkbox[i].checked)
            {
                array[j]=checkbox[i].value;
                j++;
            }

        }
        var product_filter=0;

        if(array.length>0){
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }});
            $.ajax({

             url:'<?= url('Search/'.$Cat1.'/'.$Cat2.'/'.$Cat3.'/page') ?>',
                type:"POST",
                data:'filter_id='+array+'&product_action='+product_action+'&price='+values+ '&search=' + search_text+'&product_filter='+product_filter,
                success:function(data)
                {
                    $("#products").html(data);
                }
            });


        }
        else{

            product_filter=1;
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });
            $.ajax({

             url:'<?= url('Search/'.$Cat1.'/'.$Cat2.'/'.$Cat3.'/page') ?>',
                type: "POST",
                data:'filter_id='+array+'&product_action='+product_action+'&price='+values+'&cat_id='+cat_id+'&product_filter='+product_filter,
                success: function (data) {
                    $("#products").html(data);
                }
            });

        }

    });
    search=function(cat_id)
    {
        alert(6);
        var cat_id=cat_id;
        var search_text=document.getElementById('search_box').value;
        var checkbox=document.getElementsByClassName('filter_product');
        var array=new Array();
        var j=0;
        for (var i = 0; i < checkbox.length; i++) {
            if (checkbox[i].checked) {
                array[j] = checkbox[i].value;
                j++;
            }

        }
        var product_filter=0;




        if(array.length>0) {
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });
            $.ajax({

              url:'<?= url('Search/'.$Cat1.'/'.$Cat2.'/'.$Cat3.'/page') ?>',
                type: "POST",
                data: 'filter_id=' + array + '&product_action=' + product_action + '&price=' + values + '&search=' + search_text+'&cat_id='+cat_id+'&product_filter='+product_filter,
                success: function (data) {
                    $("#products").html(data);
                }
            });
        }

        else{

            product_filter=1;

            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });
            $.ajax({

             url:'<?= url('Search/'.$Cat1.'/'.$Cat2.'/'.$Cat3.'/page') ?>',
                type: "POST",
                data: 'filter_id=' + array + '&product_action=' + product_action + '&price=' + values + '&search=' + search_text+'&cat_id='+cat_id+'&product_filter='+product_filter,
                success: function (data) {
                    $("#products").html(data);
                }
            });


        }
    }
    set_compare=function(compares_id,proId)
    {
        alert(7);
        var compares_id=compares_id;
        var checkbox=document.getElementsByClassName('compare_product');
        var pro_id=document.getElementById('compare_'+proId);


        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }});
        $.ajax({

            url:'<?= url('Compare') ?>',
            type:"POST",

            data:'product_id='+compares_id,
            success:function(data)
            {
                $("#compare").html(data);
                pro_id.style.display='none';
            }
        });
    };
    del_order=function(key)
    {
        alert(8);
        var this_url=window.location.href;
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }});
        $.ajax({

            url:'<?= url('delete_Compare') ?>',
            type:"POST",
            data:'key='+key,
            success:function()
            {
                window.location.assign(this_url);
            }
        });
    };
    check_user=function()
    {
        alert(9);
            <?php
            $check=Auth::check();
            if($check)
            {
                $a=1;
            }
            else
            {
                $a=0;
            }
            ?>

        var check='<?= $a ?>';
        if(check==1)
        {
            window.location='<?= url('Shipping') ?>'
        }
        else
        {
            window.location='<?= url('login') ?>'
        }
    }



</script>

@endsection

0 likes
0 replies

Please or to participate in this conversation.