At initial stage Url is http://localhost/laravel/
When i click on the product menu URL changes to http://localhost/laravel/#products
When i click on the product button URL changes to http://localhost/laravel/13
What i mean is that i need URL just look like http://localhost/laravel/13/#products
My current route page, view page and controller page is given below. Could you please help me how can we add #products after product id.
Route.php
Route::get('/{category_id}', [ 'as' => 'category', 'uses' => 'HomeController@getproductDetails' ]);
home.blade.php
@foreach($product_category as $product_category_values) <li><a href="{{URL::action('HomeController@getproductDetails', $product_category_values->tbl_product_category_id)}}"> {{ $product_category_values->tbl_product_category_name }}</a></li> @endforeach
HomeController.php
public function getproductDetails($category_id) { return view('pages.home')->with('category_id', $category_id); }
Try this: @foreach($product_category as $product_category_values) <li><a href="{{URL::action('HomeController@getproductDetails', $product_category_values->tbl_product_category_id)}}#products"> {{ $product_category_values->tbl_product_category_name }}</a></li> @endforeach
Look the final href value. If you need #products only be displayed when you click the menu then you could use js to add that uri tag when you need it.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community