首先,我使用此代码进行登录:
Auth::loginUsingId($user->id);
登录很好,但Auth :: user()不保留我想要的数据。我尝试使用此代码添加一些数据:
Auth::user()->setAttribute('info', "aa");
但它不起作用。错误文本是:
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Call to a member function setAttribute() on null","file": ....
我做错了什么?如何正确登录Laravel或者将项目添加到Auth :: user()中的正确方法是什么?