The result of the route() I've shown above is unexpected to me. I would have expected the not matching parameter to become part of the querystring as shown.
Nop. I had just forgotten to add it to the sample code. The problem here is that I would know if there could be a workaround that anybody has already faced. As far as I know, this is a standard behavior but to me it's not the best one approach. Laravel should be enhanced to allow only matched keys to be on the url segments and the others to be part of the querystring.
// if there is only one parameter it just uses that even though the name is not a ,match;
>>> route('foo.bar',['idx'=>3])
=> "http://localhost/foo/bar/3"
// if there are two parameters then they are matched correctly
>>> route('foo.bar',['idy'=>1,'idx'=>3])
=> "http://localhost/foo/bar/1?idx=3"
// irrespective of the order
>>> route('foo.bar',['idx'=>3,'idy'=>1])
=> "http://localhost/foo/bar/1?idx=3"
// passing null as the first argument gives the desired output
>>> route('foo.bar',[null,'idx'=>3])
=> "http://localhost/foo/bar?idx=3"
// or if it is named
>>> route('foo.bar',['idy'=>null,'idx'=>3])
=> "http://localhost/foo/bar?idx=3"
// but only if it is the first argument
>>> route('foo.bar',['idx'=>3, 'idy'=>null])
=> "http://localhost/foo/bar/3?"
Snapey, thanks indeed for your suggestion. Memento is my second name of course. Tinker is the saver and I often forget to use it! By the way, help the others is never a waste of time. If so, don't do it.
@Dario I think he meant omitting crucial pieces of info wastes peoples time who are trying to help because they don't have all of the relevant info, not helping in general. If you notice, @snapey helps quite a bit around here.
@Cronix, you read my words omitting crucial pieces.
@Snapey, by the way, helped a lot indeed and I've explained why and what. Finally I've given a suggestion about considering what can be a waste of time and what not in order to save time in the future.
In general, I never consider waste of time helping whatever it would be the end result. I consider it experience!
By the way, Thanks guys both.