最近我从laravel 5.2升级到laravel 5.4。我从下面的代码中获取了当前登录的用户
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class UserController extends Controller
{
protected $user_id;
public function __construct(Request $request)
{
$this->request = $request;
$this->user_id = Auth::user()->id;
}
}
以上代码在5.2版本中运行良好。升级到5.4后我正在
Auth :: user() - > id为NULL
如何解决这个问题?