Support the ongoing development of Laravel.io →
posted 10 years ago
Requests
Last updated 2 years ago.
0

you can also create an 'after' filter and simply redirect the user

Route::group(['before' => 'auth], function () {
    Route::group(['after' => 'HR'], function () {
        //
    });
});
Last updated 2 years ago.
0

better would be to handle the redirection in

DashboardController@redirect

because the URI is the same e.g. '/dashboard' so there is no way for a user to land on the wrong dashboard

Last updated 2 years ago.
0

zenry : The after filter doesn't work! and you can guess I have lots of methods in each controller. SO resolving them to a single DashboardController would not work as different user types have completely different views and functionality. I just want them to see that they are at /dashboard.

Last updated 2 years ago.
0

Joker666 said:

zenry : The after filter doesn't work! and you can guess I have lots of methods in each controller. SO resolving them to a single DashboardController would not work as different user types have completely different views and functionality. I just want them to see that they are at /dashboard.

yes, I forgot the after filter is done after the request

does this work?

Route::filter('userType', function() {
	switch(Auth::user()->type)
	{
		case 'MD':
			Session::put('user.dashboard', 'MDProfileController@index');
			break;
		case 'DME':
			Session::put('user.dashboard', 'DMEController@index');
			break;
	}
});

Route::group(['before' => 'auth|userType'], function() {

	Route::get('dashboard', [
		'as'   => 'dashboard',
		'uses' => Session::get('user.dashboard', 'FallbackController@dashboad')
	]);

});
Last updated 2 years ago.
0

It doesn't work at the first attempt. Goes to the fallbackcontroller. but when I reload it takes me to the desired controller's view. How to solve that?

And bigger question is even if i solved it using filter like this. it redirects me to the index of the controllers, but I have other methods(not put in the code because it will get bigger), how to do that. Using all the routing logic in the filter is bad coding I guess.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Joker666 joker666 Joined 22 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.