php - Laravel 5 route same urls login or not -


i updating site laravel 4 5. in l4 had set up:

if(sentry::check()){    route::get('/', array('as' => 'school.home.index', 'uses' => 'school\authschoolcontroller@index')); else{  route::get('/', 'school\schoolcontroller@index'); } 

note same url different controllers depending on login or not.

with l5 cannot use middleware tried this:

route::get('/', 'schoolcontroller@index');  route::group(['middleware' => 'auth'], function() {        route::get('/', array('as' => 'school.home.index', 'uses' => 'authschoolcontroller@index')); }); 

but passes on first , goes group, gets redirected login page , admin if logged in.

so think need if/else equivalent in route based on login auth::user() doesn't seem work:

if(auth::check()){   route::get('/', array('as' => 'school.home.index', 'uses' => 'authschoolcontroller@index')); } else{  route::get('/', 'schoolcontroller@index'); } 

try reordering routes so:

route::group(['middleware' => 'auth'], function() {        route::get('/', array('as' => 'school.home.index', 'uses' =>     'authschoolcontroller@index')); });  route::get('/', 'schoolcontroller@index'); 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -