Shopping cart poblem sorting shopping cart

时间:2019-01-15 18:09:15

标签: php laravel

I have controller

public function category(Categories $category)
{
    $product_random = DB::table('products')->where('is_active', 1);
    $currency = DB::table('currency')->where('id', 1)->get();
    if(count($category->children))
    {
        $categories = Categories::where('parent_id', $category->id)->get();
        return view('catalog2', compact('category', 'categories', 'product_random', 'currency', 'category_id'));
    }
    else
    {
        $categories = Categories::where('parent_id', null)->get();
        $categories_pod = Categories::where('parent_id', $category->id)->get();
        $product_s = Product::where('is_active', 1)->get();
        $product = product::where('category_id', $category->id)->where('is_active', 1)->get();
        if($price = request('individualprice'))
        {
            $product->orderBy('individualprice', $price);
        }
        return view('products', compact('category', 'product', 'categories', 'currency', 'product_s','categories_pod'));
    }
}   

and BLADE

<div><a href="?price=desc">Sort by price descending</a></div>
<div><a href="?price=asc">Sort by price</a></div>

0 个答案:

没有答案