redirect - laravel 5 Blade 如何在 Blade 模板中重定向

标签 redirect laravel-5 laravel-blade

我是 Laravel 的新手。我有 View ( Blade 模板)文件,并希望仅限登录用户访问此文件。我知道可以这样做...

@if(Auth::check())
// user is logged in. Display page
@else
// Now, user not logged in, how do i redirect to the login page
@endif

感谢您的帮助

最佳答案

View 并不意味着控制请求流。这是由 Controller 完成的。

在您的routes.php文件中:

Route::group(['middleware' => ['auth']], function () {
  Route::get('/','DashboardController@home');
}); 

关于redirect - laravel 5 Blade 如何在 Blade 模板中重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38902699/

相关文章:

php - 我无法在 Laravel 5.1 中向 Blade 发送变量

php - 我可以在 Laravel 之外使用 Blade 模板引擎吗?

java - 为什么 Spring Web/MVC 不将我的模型属性添加到我的重定向 View 的 URL 中?

.htaccess - 简单的 Youtube + Htaccess 重定向

Laravel:使用 old() 处理未选中的复选框

laravel-5 - Laravel Dusk 中的测试焦点

php - 如何在 Eloquent Laravel 中获取查询的中间数?

java - 使用 iptables 重定向端口时,Hibernate 无法打开连接

bash - 子shell IO重定向

php - 使用 Laravel 进行 GEO 位置查询 PHP 和 SQL