<?php

namespace App\Http\Resources\Results;

use Illuminate\Http\Resources\Json\JsonResource;

class ExecutingPartyGroupResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param \Illuminate\Http\Request $request
     * @return array
     */

    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'title' => $this->title,
            'department' => $this->discipline ? $this->discipline->title : null,
            'companies' => $this->executingPartyGroupCompany ? ExecutingPartyGroupCompanyResource::collection($this->executingPartyGroupCompany) : [],
            'members' => $this->executingPartyGroupMember ? ExecutingPartyGroupMemberResource::collection($this->executingPartyGroupMember) : [],
        ];
    }
}
