2017-05-15 99 views
0

我嘗試在laravel 5.4中進行多重身份驗證,最後登錄後,我想顯示用戶名稱使用此代碼{{ $show = auth:dokter()→username; {{ $show }} 但錯誤是「調用未定義的方法Illuminate \ Auth \ SessionGuard :: dokter (),你可以幫我,請錯誤多登錄Laravel

+0

請在'auth.php'集' '司機'=>「eloquent'' –

+0

在後衛?我已經這樣做了,但在提供者中, –

+0

不會'\ Auth :: user() - > username'工作嗎? – apokryfos

回答

1

那麼你應該使用Auth::user()->username應該爲你做的伎倆,但如果你想確保一個特定的守衛工作,也許包裝它是這樣的(我猜你在你的刀模板)這樣的邏輯:

@if (Auth::guard('doktor')->check()) 
    Auth::user()->username 
@endif 

if語句,如果將非盟返回true經過驗證的用戶有警衛'doktor',如果返回true,則可以回顯他們的姓名。