Support the ongoing development of Laravel.io →
Architecture

Before L5, in L4 i had a few filters for AUTH like:

Route::filter('guest', function() {
	if (Auth::check())
		return Redirect::to('/login');
});

Route::filter('auth', function() {
	if (Auth::guest()) {
		Session::put('redirect_after_login', Request::url());
		
		return Redirect::to('/login');
	}
});

In my Routes.php all routes was in two groups: with and without auth filter. How now do this? Should I include $this->middleware('auth'); in each controller or may somehow specify the same two groups?

Last updated 3 years ago.
0

how about route groups docs

Route::group(['middleware' => 'auth'], function()
{
...
});
0

Sign in to participate in this thread!

Eventy

Your banner here too?

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.

© 2025 Laravel.io - All rights reserved.