1

I am trying to build up my routes file and for the application we are building we may have a route such as:

/services/{game}/{id}

Is there a way to have that {game} parameter, but not actually pass it to the controller? Its basically there, but doesn't have to be anything specific and the controller doesn't need to know its there, it's purely for the users eye to make their URL make sense.

2 Answers 2

2

That is perfectly possible, you can catch it in the controller without doing anything with it, however you will have to catch it.

Sign up to request clarification or add additional context in comments.

3 Comments

But I still have to define the action as function blah($game, $id)
That's correct, but you wont have to do anything with the value.
However, you might want to see it the value makes sense ofcourse, because when you do nothing with it, they can put anything in that url, so you might wanna check if it is an actual game or not.
0

Do what Bielco said or just minify your route using slugs instead 2 parameters.

For example:

  • Game: Skyrim Legendary Edition
  • Slug (unique): skyrim-legendary-edition
  • Your route: /services/game/skyrim-legendary-edition

In Laravel routes.php

Route::get('services/games/{slug}', 'ServicesController@showGame');

1 Comment

This isn't really what I was going for, I am not doing this for SEO purposes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.