123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace App\Http\Resources\API;
- use App\Models\User;
- use Illuminate\Http\Request;
- use Illuminate\Http\Resources\Json\JsonResource;
- class TaskDetailResource extends JsonResource
- {
- /**
- * Transform the resource into an array.
- *
- * @return array<string, mixed>
- */
- public function toArray(Request $request): array
- {
- $whitelist=make_array_list($this->whitelist??'');
- $whitelistName=User::query()->whereIn('id',$whitelist)->get();
- $mailto=$this->mailto;
- $mailtoName=User::query()->whereIn('id',$mailto)->get();
- return [
- "id" => $this->id,
- "name" => $this->name,
- "project_id" => $this->project_id,
- "project" => new ProjectSimpleResource($this->project),
- "requirement_id" => $this->requirement_id,
- "requirement" => new RequirementSimpleResource($this->requirement),
- "requirement_group_id"=> $this->requirement_group_id,
- "naming_rule_id" => $this->naming_rule_id,
- "naming_rule" => new NamingRuleSimpleResource($this->namingRule),
- "naming_custom_fields" => $this->naming_rules,
- "parent_id" => $this->parent_id,
- "task_type" => $this->task_type,
- "doc_stage" => $this->doc_stage,
- "doc_type" => $this->doc_type,
- "status" => $this->status,
- 'approval_status' => $this->approval_status,
- "assign" => $this->assign,
- 'description' => $this->description ? (new \App\Services\File\ImageUrlService)->getImageUrl($this->description) : null,
- "begin" => $this->begin,
- "end" => $this->end,
- "mailto" => $mailto,
- "mailto_name" =>UserProfileResource::collection($mailtoName),
- "email_subject" => $this->email_subject,
- "acl" => $this->acl,
- "whitelist" => $whitelist,
- "whitelist_name"=>UserProfileResource::collection($whitelistName),
- "closed_by" => new UserProfileResource($this->closedBy),
- "closed_at" => $this->closed_at,
- "canceled_by" => new UserProfileResource($this->canceledBy),
- "canceled_at" => $this->canceled_at,
- "approve_by" => new UserProfileResource($this->approveBy),
- "approve_at" => $this->approve_at,
- "finished_by" => new UserProfileResource($this->finishedBy),
- "finished_at" => $this->finished_at,
- "review_by" => new UserProfileResource($this->reviewBy),
- "review_at" => $this->review_at,
- "created_by" => new UserProfileResource($this->createdBy),
- "custom_fields" => $this->custom_fields,
- "created_at" => (string)$this->created_at,
- "updated_at" => (string)$this->updated_at,
- "containers" => ContainerSimpleResource::collection($this->containers),
- ];
- }
- }
|