Lestah
149
3
Laravel

trying to pass url variable but i got this NotFoundHttpException

Posted 3 months ago by Lestah

here's my listing.blade.php


 @foreach($categories as $cat)
                <ul>
                    <li class=""><a href="{{ url('/products/'.$cat->url ) }}">{{ $cat->name }}</a></li>    
                </ul>
@endforeach


here's my controller


public function products($url = null)
    {
        $categories = Category::where('parent_id', 0)->get();
        $productsAll = Product::where('url', $url)->get();
      

        return view('products.listing')->with(compact('categories','productsAll'));   
    }

here's my route


Route::get('/products/{url}','[email protected]');

Im just trying to get this output

localhost:8000/products/mobile

whenever i click the href

I'm just getting this with the error

localhost:800/products/

reason why i get to the error page NotFoundHttpException

not getting the url mobile that i pass what could be wrong?

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

Reply to

Use Markdown with GitHub-flavored code blocks.