I have a SEO project with Laravel, I want to use the routes to config a friendlys dynamic urls. This is my route:
# Designs
Route::get('/d/{article}-{tag}-{design_name}-{design_id}',['as' => 'web.product_design', 'uses' => 'ProductController@getProductDesign']);
I want to build this SEO friendly url: /mug-harry-potter-wingardium-leviosa-xfdsfsdf
And that's what I call the route into any laravel blade view:
route('web.product_design',['article' => 'mug'), 'tag' => str_slug('Harry Potter'), 'design_name' => str_slug('Wingardium Leviosa'), 'design_id' => 'xfdsfsdf'])
The problem is that inside the ProductController I don't receive these parameters as I would like. I think Laravel confuses when it starts and when it finishes the slugs. For example, in the controller method...
# Product Design Page
public function getProductDesign($article,$tag,$design_name,$design_id) {
dd($article); // It gives me back 'mug', that's right.
dd($tag); // It return me 'harry', is WRONG, I want to get 'harry-potter'.
dd($design_name); // It return me 'potter', is WRONG, I want to get 'wingardium-leviosa'.
dd($design_id); // It return me 'wingardium-leviosa-xfdsfsdf', is WRONG, I want to get 'xfdsfsdf'.
}
How can I build a url SEO friendly and at the same time be able to take the parameters correctly within the controller method?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire