知乎系列中user()->password; 取不到值问题

在知乎系列 修改密码中
我用 $e=user()->password; 取值报错

FatalErrorException in UserInfoController.php line 15:
Call to undefined function App\Http\Controllers\mgr\user()

但是我已经引用了auth
而用 echo $e=auth::user()->password;则正常
这个是为什么呢 既然已经使用 use auth 为什么还要加入类名才可以 不能直接使用方法

namespace App\Http\Controllers\mgr;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use auth;
class UserInfoController extends Controller
{
        public function changePassword(){
        echo $e=user()->password;
      dd($e);
        return view ('Mgr.changepassword');
    }
JellyBool

记得composer dump autoload …

和 use Auth;大小写是有区别的

lywindly
namespace App\Http\Controllers\mgr;
use Illuminate\Auth\Authenticatable;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
//use App\Http\Controllers\Auth;
use Auth;

结果还是一样 JB 麻烦讲明白一点 谢谢

curder 回复 lywindly

检查函数 user() 中定义的代码。

JellyBool 回复 curder

@lywindly 是跳着视频看的,估计都没有看 user() 是怎么定义的

curder 回复 JellyBool

那就回头看下源代码吧?@JellyBool 有将源代码放到github上。地址: https://github.com/JellyBool/zhihu-app

canihelpyou

user()要预先定义吗?在哪一节讲的,我也遇到同样的问题。