I was working in one Laravel
Project using 92Five
App. when access user List. its goto Something Went Wrong Page. Its Display Array to string conversion Error
in Error Log.
我使用92Five App在一个Laravel项目中工作。当访问用户列表时。它转到了一些错误的页面。其显示数组到错误日志中的字符串转换错误。
In User Controller Following Functions are Defined.
在用户控制器中定义了以下功能。
Error :
[2016-08-09 13:13:12] log.ERROR: Something Went Wrong in User Repository - getAllUsersData():Array to string conversion [] []
[2016-08-09 13:13:12] log.ERROR:用户存储库中出现错误 - getAllUsersData():数组到字符串转换[] []
My Code :
我的代码:
public function getAllUsersData()
{
try{
$users = array();
$tempUsers = \User::all()->toArray();
$users = $this->getGroupBaseRole($tempUsers);
return $users;
}
catch (\Exception $e)
{
\Log::error('Something Went Wrong in User Repository - getAllUsersData():'. $e->getMessage());
throw new SomeThingWentWrongException();
}
}
public function getGroupBaseRole($groupMembersInfo) {
$data = [];
if(!empty($groupMembersInfo) && isset($groupMembersInfo)) {
foreach($groupMembersInfo as $user)
{
$banned = false;
$suspended = false;
$loginAttempt = 0;
$usersThrottle = \Throttle::where('user_id',$user['id'])->get()->toArray();
// print_r($usersThrottle); exit;
if(sizeof($usersThrottle) != 0)
{
foreach($usersThrottle as $userThrottle)
{
if($userThrottle['banned'] == true)
{
$banned = true;
}
if($userThrottle['suspended'] == true)
{
$suspended = true;
}
$loginAttempt = $loginAttempt + $userThrottle['attempts'];
}
$user['banned'] = $banned;
$user['suspended'] = $suspended;
$user['loginAttempt'] = $loginAttempt;
}
else
{
$user['banned'] = false;
$user['suspended'] = false;
$user['loginAttempt'] = 0;
}
$groupUser = \Sentry::findUserById($user['id']);
$groups = $groupUser->getGroups()->toArray();
if(sizeof($groups)!=0)
{
$user['role'] =$groups[0]['name'];
}
else
{
$user['role'] = '';
}
$data[] = $user;
}
}
return $data;
}
1 个解决方案
#1
0
It seeems getGroupBaseRole()
method accepts string, but you're trying to pass an array $tempUsers
as first argument.
它看起来getGroupBaseRole()方法接受字符串,但你试图传递数组$ tempUsers作为第一个参数。
#1
0
It seeems getGroupBaseRole()
method accepts string, but you're trying to pass an array $tempUsers
as first argument.
它看起来getGroupBaseRole()方法接受字符串,但你试图传递数组$ tempUsers作为第一个参数。