Welcome Guest, Not a member yet? Register   Sign In
How to setup a single route with optional argument
#9

(12-13-2023, 10:51 PM)ozornick Wrote: Why is the two route option not suitable for you? It's 100% working. You need to determine the required parameter based on the request

It's not that the solutions presented don't work for me. My problem is solved, thanks to you! My question is that the implementation does not comply with the documentation. From the docs


Quote:With regular expressions, you can also catch a segment containing a forward slash (/), which would usually represent the delimiter between multiple segments.

For example, if a user accesses a password protected area of your web application and you wish to be able to redirect them back to the same page after they log in, you may find this example useful:


PHP Code:
<?php

$routes
->get('login/(.+)''Auth::login/$1'); 

But that's not the case, unless you rely on variable-length argument lists, i.e., multiple arguments. 
Maybe we need to add this info/tip to the docs (or your example using "..."), otherwise that '$1' could lead the user to use only one method argument thinking one could catch all segments containing a forward slash in this single variable. 
It's just a suggestion since I find it very hard to figure it out that we had to use variable-length arguments.
Reply


Messages In This Thread
RE: How to setup a single route with optional argument - by bgeneto - 12-14-2023, 03:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB