*/ public function toArray(Request $request): array { // $assets = []; // foreach ($this->assets as $asset){ // $assets[] = new SimpleAssetResource($asset); // $assetIds[] = $asset->id; // } // $plans = []; // foreach ($this->plans as $plan){ // $plans[] = new SimplePlanResource($plan); // $plansIds[] = $plan['id']; // } $whitelist=make_array_list($this->whitelist??''); $whitelistName=User::query()->whereIn('id',$whitelist)->get(); return [ 'id' => $this->id, 'name' => $this->name, 'code' => $this->code, 'status' => $this->status, 'const' => $this->const, 'begin' => $this->begin, 'end' => $this->end, //'available_days' => $this->available_days, 'latitude' => $this->latitude, 'longitude' => $this->longitude, 'type' => $this->type, 'acl' => $this->acl, 'assets' =>SimpleAssetResource::collection($this->assets), 'plans' =>SimplePlanResource::collection($this->plans), 'approval_status'=>$this->approval_status, "whitelist" => $whitelist, "whitelist_name"=>$whitelistName, 'description' => $this->description?(new \App\Services\File\ImageUrlService)->getImageUrl($this->description):null, 'requirement_total'=>$this->requirements->count(), 'task_total'=>$this->tasks->count(), "cost_unit"=>$this->cost_unit, ]; } }