Laravel 5 - 在auth不工作之前

Today I tried to make some changes to my application. I tried to pass all pages through authentication first. I tried one of the answer on this site. But that didn't help. Please help. Here's my code in routes.php

<?php

Route::get('/', function(){
return view('homepage');
});


Route::controllers([
    'auth' => 'Auth\AuthController',
    'password' => 'Auth\PasswordController',
]);
Route::group(['before' => 'auth'], function () {
    Route::get('home', function(){
        return \Redirect::to('twitter');
    });

   Route::get('twitter', 'HomeController@index');
   .
   .
   .
   .
});

There are several routes in my file. But only twitter route works.

In laravel 5,

['before' => 'auth']

is deprecated. But instead, I should use

['middleware' => 'auth']

Laravel5 has middlewares instead of filter. I assume you are trying to show certain page to only guests and for that we have a guest middleware already built in.

Route::group(['middleware' => 'guest'], function () {
Route::get('home', function(){
    return \Redirect::to('twitter');
});

Route::get('twitter', 'HomeController@index');
});

you may also use middlewares on particular functions of your controller if you want, e.g

class MyController extends Controller {

public function __construct()
{
    //to add auth middleware only on update method 
    $this->middleware('auth', ['only' => 'update'])
    //to add auth middleware on all fucntions expcept login
    $this->middleware('auth', ['except' => 'login'])
}

}