PM_Console/backend/app/Http/Resources/ProjectResource.php

47 خطوط
1.9 KiB
PHP

<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class ProjectResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'title' => $this->title,
'description' => $this->description,
'client' => $this->client,
'project_manager_id' => $this->project_manager_id,
'project_manager' => new UserResource($this->whenLoaded('projectManager')),
'department_id' => $this->department_id,
'department' => $this->whenLoaded('department', fn () => [
'id' => $this->department?->id,
'name' => $this->department?->name,
'type' => $this->department?->type,
]),
'members' => UserResource::collection($this->whenLoaded('members')),
'start_date' => $this->start_date?->format('Y-m-d'),
'end_date' => $this->end_date?->format('Y-m-d'),
'priority' => $this->priority,
'status' => $this->status,
'progress' => $this->progress,
'risk_level' => $this->risk_level,
'budget' => $this->budget,
'estimated_hours' => $this->estimated_hours,
'actual_hours' => $this->actual_hours,
'tags' => $this->tags,
'notes' => $this->notes,
'is_archived' => $this->is_archived,
'created_by' => $this->created_by,
'creator' => new UserResource($this->whenLoaded('creator')),
'tasks_count' => $this->when($this->tasks_count !== null, $this->tasks_count),
'meetings_count' => $this->when($this->meetings_count !== null, $this->meetings_count),
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}