theres too much information to understand
Use slug to display Post category
Sorry if this seems like a broad question but here is the issue.
I have a route like so.
/listings/{slug}/{uuid}
Here is the blades link
href="{{route('listing.single.page', ['slug'=>$latest_listing->category->slug, 'id'=>$latest_listing->id])}}" class="blog-compact-item-container"
I removed anchor because laracast changes it to link.
This works with no issues. It displays the single listing and shows the category slug in URL fine. So the output link is something like this. /listings/room_for_rent/randomUUID
The problem is with the other function in my controller. I want the route "/listings/{slug}" to dislpay the category page but the url with the slug like this "/listings/room_for_rent" doesnt work.
Here is the controller:
//Category listing page for listings
public function listing_category_page($listingcategory_id){
$show_listing_category = Listing::with('category', 'user')->where('verified', '=', '1')->where('listingcategory_id', $listingcategory_id)->latest()->paginate(10);
$show_listing_category_detail = ListingCategory::findOrFail($listingcategory_id);
return view('/front-end/category-pages/show_listing_category', compact('show_listing_category', 'show_listing_category_detail'));
}
So in my table "listing" has listingcategory_id column. I am currently taking that value to display the URL so it comes like /listings/2 and not slug.
The slug is in my other table which is the "listing_categories" table. That table contains the slug column. The above mentioned route is taking the slug from that table.
My question is, how can i do the same to display listings using slug for that category instead of using the listingcategory_id column. Do i have to create a slug for listing table too? I am taking the slug from listing_categories table and i want the route to change to /listings/{slug} not /listings/{listingcategory_id}. With the current code posted above, i dont know how to achieve this because the slug is in another table which is related to listings table.
Here is my route:
Route::get('/listings/{listingcategory_id}/', 'FrontEnd\FrontEndController@listing_category_page')->name('listing.single.category.page');
Thanks
Please or to participate in this conversation.