我在十月 CMS 中建立一個網站,我安裝了rainlab.user 插件用于用戶帳戶管理。現在我正在嘗試創建名為“UserDetails.php”的自定義組件。我可以使用{{ user.username }}. 但我需要在UserDetails.php 中獲取該用戶名。我怎樣才能做到這一點?你能幫我一下嗎?提前致謝。!!
uj5u.com熱心網友回復:
您可以使用Rainlab.user插件Auth facade獲取當前登錄用戶的詳細資訊。
你可以使用下面的代碼
參考:https : //tutorialmeta.com/octobercms/october-cms-access-logged-user-rainlab-user-plugin
use Auth;
// it will returns the current logged in user
$user = Auth::getUser();
if($user) {
dd($user->username);
}
// further more to check if any user logged in or not you can use
// it will return true if user is logged in
$loggedIn = Auth::check();
dd($loggedIn);
如果有任何疑問,請發表評論。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/403667.html
標籤:
下一篇:Laravel控制器中的表連接
