Because each page requires the information of the currently logged in user
So I want to get the authentication information in the parent Controller(__construct) and share it with all views!
The problem now is that neither of these two places can obtain login user information
//You won’t let me set data everywhere I need it...
仅有的幸福2017-06-06 09:56:18
Read the manual http://laravelacademy.org/pos... This feature has been changed since laravel5.3.
某草草2017-06-06 09:56:18
//现在的处理方式, 为了取个登录用户这样子写有点那啥哦...
public function __construct()
{
$this->middleware(function($request, $next) {
$this->loginUser = $this->getUser();
//$this->loginUser = $request->user();
view()->share('loginUser', $this->loginUser);
return $next($request);
});
}