@Snapey
I am facing the same error but unable to resolve tried the same thing as well below is the code which is giving the error Can you please help me to resolve
$user = $this->userRepository->findWithoutFail(auth()->id());
unset($user->password);
$customFields = false;
$bannedRoles = $user->getRoleNames()->map(function ($element) {
return config('permission.banned_roles')[$element];
})->toArray();
if (auth()->user()->hasRole('institution')) {
array_push($bannedRoles[0], "driver", "dispatcher", "client", "manager", "employee");
}
$bannedRoles = array_merge(...$bannedRoles);
$role = $this->roleRepository->whereNotIn('name', $bannedRoles)->pluck('name', 'name');
if (auth()->user()->hasRole('admin') || auth()->user()->hasRole('Super Admin')) {
$townHall = $this->townHallRepository->pluck('name', 'id');
} else {
$townHall = $this->townHallRepository->myMarkets()->pluck('name', 'id');
}
$rolesSelected = $user->getRoleNames()->toArray();
$customFieldsValues = $user->customFieldsValues()->with('customField')->get();
//dd($customFieldsValues);
$hasCustomField = in_array($this->userRepository->model(), setting('custom_field_models', []));
if ($hasCustomField) {
$customFields = $this->customFieldRepository->findByField('custom_field_model', $this->userRepository->model());
$customFields = generateCustomField($customFields, $customFieldsValues);
}
$townHall = $townHall->toArray();
$townHall[null] = null;
$riderTypes = $this->riderTypesRepository->getRiderTypes()->pluck('name', 'id');
return view('settings.users.profile')
->with("user", $user)
->with("role", $role)
->with('townHall', $townHall)
->with("customFields", isset($html) ? $html : false)
->with("rolesSelected", $rolesSelected)
->with('riderTypes', $riderTypes)
->with('riderIdSelected', null);
}