📌  相关文章
📜  如何修复未定义变量:产品(查看:C:\xampp\htdocs\ecommerce\resources\views\livewire\shop-component.blade.php) - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:21.105000             🧑  作者: Mango

代码示例1
}    public function store($product_id,$product_name,$product_price)    {        Cart::add($product_id,$product_name,1,$product_price)->associate('App\Models\Product');        session()->flash('success_message','Item added in cart');        return redirect()->route('product.cart');    }    use WithPagination;    public function render()    {        if($this->sorting=='date')        {            $products = Product::orderBy('created_at','DESC')->paginate($this->pagesize);        }else if($this->sorting=="price"){            $products = Product::orderBy('regular_price','ASC')->paginate($this->pagesize);        }else if ($this->sorting=="price-desc") {            $products = Product::orderBy('regular_price','DESC')->paginate($this->pagesize);         }else {            $products = Product::paginate($this->pagesize);         }         $categories = Category::all();          return view('livewire.shop-component', ['products'=> $products])->layout("layouts.base");    }}