Answers for "how to fix Undefined variable: product (View: C:\xampp\htdocs\ecommerce\resources\views\livewire\shop-component.blade.php)"

PHP
0

how to fix Undefined variable: product (View: C:\xampp\htdocs\ecommerce\resources\views\livewire\shop-component.blade.php)

     }    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");    }} 
Posted by: Guest on October-20-2021

Code answers related to "how to fix Undefined variable: product (View: C:\xampp\htdocs\ecommerce\resources\views\livewire\shop-component.blade.php)"

Browse Popular Code Answers by Language