Chatter 无法识别 Laravel 5.4 中的 Auth::user
Chatter doesn't recognize Auth::user in Laravel 5.4
Hell0,我在安装过程中没有任何错误和一切(使用此说明):
https://github.com/thedevdojo/chatter
顺利通过,出现 0 个错误,一切看起来都很好,但是当我登录时它无法识别我的用户。
dd(Auth::user()); return 错误。
如果我在视图和控制器中使用 "Auth::guard('webfront')->user()" 而不是 "Auth::user()",它会获取会话并向我显示 post 的表单。但是当我尝试 post 时,它会将我重定向回登录页面(当我仍然登录时)。
只有一件事困扰着我...主要系统控制器位于:
"App\Http\Controllers\Frontend..." 和 "App\Http\Controllers\Frontend\Auth"
视图的文件夹名称也相同。起初,当我试图强制 "use Auth;" 使用 "App\Http\Controllers\Frontend\Auth;" 但它 return 找不到 class "App\Http\Controllers\Frontend\Auth"
有人遇到过这个问题吗?任何解决方案?谢谢:-)
已修复:对于遇到同样问题的每个人。您必须编辑 chatter.php 配置文件,并将您使用的中间件的 ID 添加到它们的字段中,例如:
'middleware' => [
'global' => ['web'],
'home' => [],
'discussion' => [
'index' => [],
'show' => [],
'create' => ['auth:webfront'],
'store' => ['auth:webfront'],
'destroy' => ['auth:webfront'],
'edit' => ['auth:webfront'],
'update' => ['auth:webfront'],
],
'post' => [
'index' => [],
'show' => [],
'create' => ['auth:webfront'],
'store' => ['auth:webfront'],
'destroy' => ['auth:webfront'],
'edit' => ['auth:webfront'],
'update' => ['auth:webfront'],
],
'category' => [
'show' => [],
],
],
Hell0,我在安装过程中没有任何错误和一切(使用此说明):
https://github.com/thedevdojo/chatter
顺利通过,出现 0 个错误,一切看起来都很好,但是当我登录时它无法识别我的用户。
dd(Auth::user()); return 错误。
如果我在视图和控制器中使用 "Auth::guard('webfront')->user()" 而不是 "Auth::user()",它会获取会话并向我显示 post 的表单。但是当我尝试 post 时,它会将我重定向回登录页面(当我仍然登录时)。
只有一件事困扰着我...主要系统控制器位于:
"App\Http\Controllers\Frontend..." 和 "App\Http\Controllers\Frontend\Auth"
视图的文件夹名称也相同。起初,当我试图强制 "use Auth;" 使用 "App\Http\Controllers\Frontend\Auth;" 但它 return 找不到 class "App\Http\Controllers\Frontend\Auth"
有人遇到过这个问题吗?任何解决方案?谢谢:-)
已修复:对于遇到同样问题的每个人。您必须编辑 chatter.php 配置文件,并将您使用的中间件的 ID 添加到它们的字段中,例如:
'middleware' => [
'global' => ['web'],
'home' => [],
'discussion' => [
'index' => [],
'show' => [],
'create' => ['auth:webfront'],
'store' => ['auth:webfront'],
'destroy' => ['auth:webfront'],
'edit' => ['auth:webfront'],
'update' => ['auth:webfront'],
],
'post' => [
'index' => [],
'show' => [],
'create' => ['auth:webfront'],
'store' => ['auth:webfront'],
'destroy' => ['auth:webfront'],
'edit' => ['auth:webfront'],
'update' => ['auth:webfront'],
],
'category' => [
'show' => [],
],
],