Fix Private Profile fields not being editable (#1289)
* Update ProfileController.php * Update UserRepository.php * Update UserRepository.php Co-authored-by: Nabeel S <nabeelio@users.noreply.github.com>
This commit is contained in:
parent
57277c558d
commit
fc8ca69729
@ -123,7 +123,7 @@ class ProfileController extends Controller
|
||||
|
||||
$airlines = $this->airlineRepo->selectBoxList();
|
||||
$airports = $this->airportRepo->selectBoxList(false, setting('pilots.home_hubs_only'));
|
||||
$userFields = $this->userRepo->getUserFields($user, true);
|
||||
$userFields = $this->userRepo->getUserFields($user);
|
||||
|
||||
return view('profile.edit', [
|
||||
'user' => $user,
|
||||
|
@ -36,9 +36,14 @@ class UserRepository extends Repository
|
||||
*
|
||||
* @return \App\Models\UserField[]|\Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection
|
||||
*/
|
||||
public function getUserFields(User $user, $only_public_fields = true): Collection
|
||||
public function getUserFields(User $user, $only_public_fields = null): Collection
|
||||
{
|
||||
if (is_bool($only_public_fields)) {
|
||||
$fields = UserField::where(['private' => !$only_public_fields])->get();
|
||||
} else {
|
||||
$fields = UserField::get();
|
||||
}
|
||||
|
||||
return $fields->map(function ($field, $_) use ($user) {
|
||||
foreach ($user->fields as $userFieldValue) {
|
||||
if ($userFieldValue->field->slug === $field->slug) {
|
||||
|
Loading…
Reference in New Issue
Block a user