Support the ongoing development of Laravel.io →
Authentication Requests Architecture

Hey guys,

what do you think about the following:

Route::get('/', Auth::check() ? 'Controller\Menu@show' : 'Controller\Login@form');

I have never used logic like that in routes.php, but is that considered wrong? I want the main page to display menu or login form, depending on the authorization status. I could provide separate routes for them, but I'd like to keep them both in root. What do you think about it?

Last updated 3 years ago.
0

What you need is a route filter, see http://laravel.com/docs/security#protecting-routes

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

kokokurak kokokurak Joined 21 Aug 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.

© 2025 Laravel.io - All rights reserved.