From 0cffcf682d1b4e2183e35f6f6e8b431bca1933bb Mon Sep 17 00:00:00 2001 From: blt950 Date: Fri, 5 Mar 2021 22:56:26 +0100 Subject: [PATCH] Fixed getInlineMentoringAreas() --- app/Models/User.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/Models/User.php b/app/Models/User.php index 36e903520..693327db5 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -245,12 +245,20 @@ public function getInlineMentoringAreas(){ $output = ""; - if($this->groups->count() > 1){ - foreach($this->groups as $group){ - $output .= Area::find($group->pivot->area_id)->name . " & "; + $areas = []; + foreach($this->groups as $group){ + $areas[$group->pivot->area_id] = Area::find($group->pivot->area_id)->name; + } + + $countMax = sizeof($areas); + $counter = 0; + foreach($areas as $area){ + if($counter == $countMax - 1){ + $output .= $area; + } else { + $output .= $area . " & "; } - } else { - $output .= Area::find($this->groups->first()->pivot->area_id)->name; + $counter++; } if(empty($output)){