我有问题... 这是我的代码。 我无法弄清楚我的代码.....
here is the error here is my user class
这是完整的DashboardController
/**
* '/home' calls this route
*
* @param none
* @return view dashboard
*/
public function index()
{
$this->permission();
$data = [
'pagetitle' => 'Dashboard',
'permission' => Session()->get('permission'),
'name' => Auth::user()->name,
];
return view('dashboard',$data);
}
/**
* Checks if session has permission in it if not they adds to it
*
* @param null
* @return null
*/
private function permission()
{
if (!Session()->has('permission')) {
$permission = User::find(Auth::user()->id)->details;
$permission_arr = [
'department' => $permission->permission_department,
'asset' => $permission->permission_asset,
'users' => $permission->permission_users,
];
Session()->put('permission', $permission_arr);
}
}
}
我不知道如何解决。 任何帮助都会很棒。.
答案 0 :(得分:1)
您遇到这种问题,因为您只能从“用户”表中访问详细信息列。从$ permission = User :: find(Auth :: user()-> id);
中删除详细信息private function permission(){
if (!Session()->has('permission')){
$permission = User::find(Auth::user()->id);
$permission_arr = [
'department' => $permission->permission_department,
'asset' => $permission->permission_asset,
'users' => $permission->permission_users,
];
Session()->put('permission', $permission_arr);
}
}
注意,我只是从您的权限变量中删除了详情对象