Update controllers and services for allocation fidelity: - AllocationController: variance data in responses, bulk operations - ProjectController: include plan data in responses - ProjectMonthPlanController: planning grid API - AllocationMatrixService: support untracked allocations - ProjectResource/TeamMemberResource: include reconciliation data Improved test coverage for allocation flows.
31 lines
1.1 KiB
PHP
31 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
class ProjectResource extends BaseResource
|
|
{
|
|
public function toArray($request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'code' => $this->code,
|
|
'title' => $this->title,
|
|
'status_id' => $this->status_id,
|
|
'type_id' => $this->type_id,
|
|
'status' => $this->whenLoaded('status', fn () => new ProjectStatusResource($this->status)),
|
|
'type' => $this->whenLoaded('type', fn () => new ProjectTypeResource($this->type)),
|
|
'approved_estimate' => $this->formatEstimate($this->approved_estimate),
|
|
'forecasted_effort' => $this->forecasted_effort,
|
|
'start_date' => $this->formatDate($this->start_date),
|
|
'end_date' => $this->formatDate($this->end_date),
|
|
'created_at' => $this->formatDate($this->created_at),
|
|
'updated_at' => $this->formatDate($this->updated_at),
|
|
];
|
|
}
|
|
|
|
private function formatEstimate(?float $value): ?string
|
|
{
|
|
return $value !== null ? number_format((float) $value, 2, '.', '') : null;
|
|
}
|
|
}
|