1
下面的代碼僅授予admin
和user_a
以查看錶單。但是我想讓表格的一部分只能讀取user_a
。如何製作可供用戶閱讀的表單並可編輯給其他用戶
@if(Auth::user()-> user_role == "admin" || Auth::user()-> user_role == "user_a")
//form
@endif
下面的代碼僅授予admin
和user_a
以查看錶單。但是我想讓表格的一部分只能讀取user_a
。如何製作可供用戶閱讀的表單並可編輯給其他用戶
@if(Auth::user()-> user_role == "admin" || Auth::user()-> user_role == "user_a")
//form
@endif
試試這個:
@if(Auth::user()-> user_role == "admin" || Auth::user()-> user_role == "user_a")
//form
// specific section
@if(Auth::user()-> user_role == "user_a")
// This section is visible to the role user_a only
@endif
@endif
謝謝現在..在輸入標籤我添加了第二個If語句。並在if語句中*只讀 – JoshGray
爲什麼不只是添加另一個'如果(AUTH ::用戶() - > USER_ROLE == 「USER_A」)'?或者你的問題到底是什麼? – Quasdunk
你不需要編寫不同的代碼,只需在你的html內容中添加只讀,當你想顯示你的內容不要編輯 – jilesh