我刚刚安装了laravel 5.2,并且我创建了auth注册,登录和重置密码,但是现在我想创建一个我的项目的索引,其中所有用户(也都未登录)都可以访问。我试图创建Laravel 5.2 - 中间件认证
Route :: get('/',HomeController @ home');
但是这个视图只对用户登录才有效。
MY ROUTES
Route::auth();
Route::get('/home', '[email protected]');
// POST - FORM CREA
Route::get('/crea-regalo', '[email protected]');
Route::post('/crea-regalo', '[email protected]');
// LISTA ANNUNCI PRINCIPALE
Route::get('/', '[email protected]');
MY HOME控制器
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$posts = Post::orderBy('id','DESC');
return view('home', compact('posts'));
}
public function home()
{
$posts = Post::all();
return view('index', compact('posts'));
}
}
如何创建视图,所有用户都可以访问路线?
谢谢你的帮助!
yup!谢谢!我将创建另一个控制器,是最好的选择! –