title: How to convert route params to query params in Lumen routes
body: <p>I am building a REST api with Lumen and encountered a problem that I did solve, but perhaps there is a more elegant way.</p>
  
  <p>I have two routes:</p>
  
  <pre><code>$app-&gt;get('profile/{profileId}', \App\Http\Controller\ProfileController::class . '@show');
  </code></pre>
  
  <p>and</p>
  
  <pre><code>$app-&gt;get('post', \App\Http\Controller\PostController::class . '@index');
  </code></pre>
  
  <p>A profile can have many posts, so I want to build a new route that is like this</p>
  
  <pre><code>$app-&gt;get('profile/{profileId}/post', \App\Http\Controller\PostController::class . '@index');
  </code></pre>
  
  <p>to get the posts of a profile.
  But I don't want to pass the {profileId} as route param to the index action of the post controller, but as a query param.</p>
  
  <p>To solve this, I changed the route to this</p>
  
  <pre><code>$app-&gt;get('profile/{profileId}/post', function ($profileId) use ($app) {
      $controller = $app-&gt;make(\App\Http\Controller\PostController::class);
  
      $request = $controller-&gt;getRequest();
      $request-&gt;query-&gt;add([
          'profileId' =&gt; $profileId,
      ]);
  
      return $controller-&gt;index($request);
  });
  </code></pre>
  
  <p>Had someone to do the same and has a better, more convenient way to do it?</p>
  
  <p>I know e.g. that I could use the dingo package to do internal request from one controller to another, but I can not use it right now.</p>