title: Namespacing in Laravel Views
body: <p>I'm creating a "modular" Laravel app where related classes are grouped into their own directories and namespaces, which mirror the structure of the <code>app/</code> directory and <code>\App</code> namespace. A service provider registers views and defines routes for each module.</p>
  
  <p>This structure works great to compartmentalize everything but a problem is in referencing controllers in views. In the main app module, to create a URL based off a controller action I can just use something like <code>{{ action('MyController@index') }}</code> because everything is relative to the <code>\App\Http\Controllers</code> namespace. In module views I have to do something like <code>{{ action('\Modules\MyModule\Http\Controllers\MyModuleController@index') }}</code> which works but is a lot to type and read, and something I need to replace every instance of if I ever rename a module.</p>
  
  <p>Is there a way to make all views loaded as part of a module use the correct namespace? This is what is in the <code>boot()</code> function of my module service provider:</p>
  
  <pre><code>foreach($this-&gt;modules as $module) { // Module names in CamelCase
      $this-&gt;loadViewsFrom(base_path('modules/' . $module . '/Resources/Views'), strtolower($module));
  }
  </code></pre>
  
  <p>which lets me reference views like <code>view('mymoduleinlowercase::folder.viewname')</code></p>
  
  <p>I can't seem to find any reference to the <code>loadViewsFrom()</code> function in the API documentation.</p>