parisan liked this thread
I personally put them in sub-folders. So I would have the following:
app/controllers/User/DashboardController.php
class UserDashboardController extends Controller {
public function index() {
return View::make('user.index');
}
}
app/controllers/Admin/DashboardController.php
class AdminDashboardController extends Controller {
public function index() {
return View::make('admin.index');
}
}
And so on.. Then your routes.php would look like:
Route::get('users/dashboard', 'UserDashboardController@index');
Route::get('admin/dashboard', 'AdminDashboardController@index');
A TIP: When doing this, you may need to run composer dump-autoload for Laravel routes to load your controllers when putting them into sub-folders.
Hopefully that helps or gets you going in the right direction.
Nice solution.
PS: There is some info about it in the documentation (4.2) ?
engrjunaidali liked this reply
grindmodeon; I'm creating a website in english and spanish, but they will have completely diferent information so the translation package will not be useful. My question is: as you use diferent folder for each controller, do I have to use different folder for each language? like: app/views/spa/Users/index.blade.php for spanish and app/controllers/eng/Users/index.blade.php for the english?
Thanks a lot for your support,
Best Regards,
I haven't tested this but I imagine something like this could work
//defined elsewhere
$langAbbreviations = ['en', 'sp', 'io'];
//routes.php
Route::pattern('lang', implode('|', $langAbbreviations));
Route::group(array('prefix' => '{lang?}'), function()
{
//define routes
});
//the correct lang prefix can then be detected by
$lang = Route::input('lang');
//which you might use in a language service which can handle language specific operations.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community