title: Create Dynamic Routing with Dynamic Prefix Group and Dynamic Controller Call
body: <p>Hope you all are doing well. I apologize for my English (I'm not a native speaker).
  Let's jump right to the matter. I'm relatively new to Laravel and I can't accomplish what I want to do.</p>
  <p>What I want to accomplish is:
  I'm building a little CMS and I have an Entry table in which I store content as blog posts but also as projects for my portfolio. Currently, I can show these two modules of entries separated from each other in the public front-end at <em>~/blog/post</em> (for posts) and <em>~/portfolio/projects</em>.( for projects).</p>
  <p>I thought of them as separated modules or domains, as you prefer to call them.</p>
  <p>Now the tricky part. In my ~/admin I create a dynamic routing to get these modules and other modules like Users, Menus, Roles, Tags, Categories, this way:</p>
  <pre><code>Route::get('{module}', function($module) 
    {
     return App::make('App\Http\Controllers\Admin\\'.ucfirst($module).'Controller')-&gt;Index();
  )-&gt;name('module');
  </code></pre>
  <p>Ok, that worked well until I added CRUD ops to the Entries (posts and projects). The first thing I did was create separated controllers, but I thought &quot;I don't want to repeat code&quot;, so I thought on use inheritance or interfaces but I'm not comfortable yet on how to do it in php.</p>
  <p>So, What I want is to maintain separated all entries marked as projects from the ones marked as posts but use the same EntryController for all CRUD ops, I thought passing the &quot;module name or id&quot; to the controller as a parameter or make the routing dynamic but I feel blocked. I did some research on how I could accomplish this and found something like this:</p>
  <pre><code>Route::Group(['prefix' =&gt; '/{module}', 'as' =&gt; 'module' ], function()
  {
      Route::get('', function($module) 
      {
          return App::make('App\Http\Controllers\Admin\\'.ucfirst($module).'Controller')-&gt;Index();
      })-&gt;name('module.index');
  
      Route::get('/{id}', function($module) {
          return App::make('App\Http\Controllers\Admin\\'.ucfirst($module).'Controller')-&gt;Delete();
      }) 
      -&gt;name(&quot;delete.{module}&quot;);
  
  // ..... AND THE REST OF THE OPERATIONS FOLLOWS THE SAME LOGIC .....
  </code></pre>
  <p>I try this too but this work having /Admin/BlogController and /Admin/PortfolioController (and is what I want to improve)</p>
  <pre><code>$module = ['blog','portfolio'];
  foreach($module as $entry)
  {
            Route::post('', 'App\Http\Controllers\Admin\\'.ucfirst($entry).'Controller@CreateEntry')
              -&gt;name(&quot;create.{$entry}&quot;);
           
              Route::post('/{id}', 'App\Http\Controllers\Admin\\'.ucfirst($entry).'Controller@DeleteEntry')
              -&gt;name(&quot;delete.{$entry}&quot;);
  
  // ............... MORE CRUD OPS .......................
      });
  
  </code></pre>
  <p>I'm feeling stuck, I'll be deeply thankful if someone can give me a hand on this.
  Thank you in advance for reading me :) best wishes to you.</p>
  <p><strong>PD: This is giving me trouble because I'm trying to maintain the url as clean as possible (e.g, ~/admin/portfolio, ~/admin/blog, ~/admin/users, ~/admin/roles, etc)</strong></p>