Skip to content

Commit b9ed446

Browse files
committed
tweaks to external resource representation
1 parent 68f0f41 commit b9ed446

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

app/Modules/Group/Http/Resources/GroupExternalResource.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
namespace App\Modules\Group\Http\Resources;
44

5+
use Illuminate\Support\Facades\URL;
56
use Illuminate\Http\Resources\Json\JsonResource;
67
use App\Modules\Group\Models\Group;
78

89
class GroupExternalResource extends JsonResource
910
{
11+
public static $wrap = 'gpm_group';
12+
1013
function __construct(Group $group)
1114
{
1215
parent::__construct($group);
@@ -25,16 +28,25 @@ public function toArray($request)
2528
'name' => $this->name,
2629
'description' => $this->description,
2730
'status' => $this->groupStatus->name,
31+
'status_date' => $this->groupStatus->updated_at,
2832
'type' => $this->type->name,
2933
'members' => $this->members->map(function ($member) {
3034
$p = $member->person;
31-
return [
35+
$personData = [
3236
'first_name' => $p->first_name,
3337
'last_name' => $p->last_name,
38+
'credentials' => $p->credentials->map(function ($credential) {
39+
return $credential->name;
40+
}),
41+
'uuid' => $p->uuid,
3442
'roles' => $member->roles->map(function ($role) {
3543
return $role->display_name;
3644
}),
3745
];
46+
if ($p->profile_photo) {
47+
$personData['profile_photo'] = URL::to('/profile-photos/' . $p->profile_photo);
48+
}
49+
return $personData;
3850
}),
3951
];
4052

@@ -43,6 +55,7 @@ public function toArray($request)
4355
$data += [
4456
'expert_panel' => [
4557
'uuid' => $ep->uuid,
58+
'affilitaion_id' => $ep->affiliation_id,
4659
'name' => $ep->long_base_name,
4760
'short_name' => $ep->short_base_name,
4861
'scope_description' => $ep->scope_description,
@@ -56,6 +69,7 @@ public function toArray($request)
5669
'current_step' => $ep->current_step,
5770
],
5871
];
72+
5973
}
6074

6175
if ($this->parent) {

0 commit comments

Comments
 (0)