mardi 20 février 2018

Laravel: Handle old url with get parameter

Before using Laravel I had a link like this:

/user.php?id=13

In Laravel I have rewritten the url to /user/13. However, I also want to maintain the old url for a couple of month. How can I retrieve it?

If I try

Route::get('/user.php', function(){
 dd("test"); 
});

then he cannot find the route, I guess because of the dot ., this is the result:

No input file specified.

If I try

Route::get('/user', function(Request $request){
  dd( $request->input('id'));
});

then /user?id=29 causes:

Call to undefined method Illuminate\Support\Facades\Request::input()

Although it is stated in the docs

Regardless of the HTTP verb, the input method may be used to retrieve user input

So how can I get the route user.php?id=13 and how to retrieve the input?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire