You_ness654987
6 months ago

404 not found

Posted 6 months ago by You_ness654987

Hi to all, Can you help me with this problem. i did pass parameter parameter from url to controller when i type the link (...//shop?category=2) it work normal but when i want to access the link ( ../shop ) without parameter i get 404 not found

my controller :

 public function index()
    {

        $category_id = request()->category;


        $categories = categories::all();
        if (empty($category_id)) {

            $products = products::inRandomOrder()->take(12)->get();
        } else {
            $products = products::where('categories_id', $category_id)->inRandomOrder()->take(12)->get();
        }

        $cat_name = categories::where('id', $category_id)->firstorFail();




        return view("shop")->with([
            'products' => $products,
            'categories' => $categories,
            'cat_name' => $cat_name,
        ]);
    }

Please sign in or create an account to participate in this conversation.