问题
I need to enable /register page to logged in users and restrict for non logged in users in laravel 5.2. I tried changing \app\Http\Controllers\Auth\AuthController.php page constructer to view /register page to logged in users but it didn't work...
public function __construct() {
$this->middleware($this->guestMiddleware(), ['except' => ['logout', 'getRegister', 'postRegister']]);
}
It would be great help if someone can look into this.
回答1:
You can add inside auth group middleware all your routes that redirect to views visible to the logged in users.
Route::group(['middleware' => ['auth']], function () {
Route::get('/register','your_controller@your_method');
});
来源:https://stackoverflow.com/questions/38701883/enable-register-page-to-logged-in-users-in-laravel-5-2