Last active
December 26, 2015 18:19
-
-
Save aranw/7193744 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Needs refactoring I guess into one, but thats a topic for another day | |
Route::filter('user', function() { | |
if (! Session::has('User')) { | |
return Redirect::to('/'); | |
} | |
}); | |
Route::filter('guest', function() { | |
if (Session::has('User')) { | |
return Redirect::to('/'); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
So, as you can see I have too routes for "/". Because the filters are redirecting, it causes a redirect loop! | |
I didn't really want just one route, and then point it to function like this: | |
function homeDelegate() { | |
if($this->is_user) { | |
return $this->dashboard(); | |
} | |
return $this->homepage(); | |
} | |
...and then have the seperate functions there. At the moment, I'm either using filters wrongly (clearly I am, but I mean more ethically) or I'm going to have to use the delegate func above. Any tips? Ideas? Cool Laravel stuff? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
|-------------------------------------------------------------------------- | |
| Home Controller Routes | |
|-------------------------------------------------------------------------- | |
| | |
| Defined routes for the Home Controller. This just handles our users | |
| dashboard (homepage). | |
| | |
*/ | |
Route::group(['before' => 'guest'], function() | |
{ | |
Route::get('/', ['as' => 'dashboard', 'uses' => 'ET\Controller\HomeController@homepage']); | |
}); | |
Route::group(['before' => 'user'], function() | |
{ | |
Route::get('/', ['as' => 'dashboard', 'uses' => 'ET\Controller\HomeController@homepage']); | |
}); | |
Route::any('/', [ | |
'before' => 'guest', | |
'as' => 'dashboard', | |
'uses' => 'ET\Controller\HomeController@homepage' | |
]); | |
Route::any('/', [ | |
'before' => 'user', | |
'as' => 'dashboard', | |
'uses' => 'ET\Controller\HomeController@dashboard' | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment