Reputation: 137
I am trying to make my website slug/url be like this localhost:8000/apartment/example-post-cat-come
instead of localhost:8000/example-post-cat-come
I have categories like 1. Apartment 2. Flat
i want to add the post category before the slug in the url
currently i am doing this
Route::get('/{post}','ShowPropertiesController@index')->name('posts.show');
i also did the following after trying with the first route
Route::get('{category}/{post}','ShowPropertiesController@index')->name('posts.show');
and did this in my controller
public function index($category, $post)
{
// ...
}
i got this error Missing required parameters for [Route: posts.show] [URI: {category}/{post}]. (View: C:\MAMP\htdocs\laravel-real-estate\resources\views\pages\welcome.blade.php)
This is my blade
<a href="{{ route('posts.show',$properties->slug) }}">{{$properties->title}}</a>
How can i make the category show before url?
Upvotes: 0
Views: 1174
Reputation: 1128
The problem is in welcome.blade.php, you should pass all required parameters to route:
<a href="{{ route('posts.show',['category' => CATEGORY, 'post' => POST]) }}">{{$properties->title}}</a>
change CATEGORY and POST with your values
Upvotes: 1