Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Sekiro's avatar

routes problem

href="products/{{ $cat['id'] }}" when i press this I load the route:

Route::get('/products/{id}', function ($id) { $products = products::where('category_id', $id)->get(); return view('products', [ 'products' => $products ]); });

somehow the page can not get any source code in css or js although they are in the public folder, it is in this one alone when I use the route without the id it loads normally

update: I used a function called asset and put each link in it and it worked but I still don't get why the problem occured

1 like
11 replies
Snapey's avatar

Probably because your css and js files are off the route folder but you are not specifying absolute route to load the assets.

In your browser, open dev tools and load the page. You might see failed requests for the css, and the path it is looking in is /products/css/your.css when it should be /css/your.css

You need to look at the layout file and the way you are linking to the files.

2 likes
vincent15000's avatar

What does your products view look like ?

Does it extend from a layout ?

1 like
Sekiro's avatar

@vincent15000 I use the x-layout for all my pages and put the content inside it , I used asset() function and it worked

Please or to participate in this conversation.