Skip to content

Commit

Permalink
Fixed getInlineMentoringAreas()
Browse files Browse the repository at this point in the history
  • Loading branch information
blt950 committed Mar 5, 2021
1 parent f949737 commit 0cffcf6
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)){
Expand Down

0 comments on commit 0cffcf6

Please sign in to comment.