- Create BaseResource with formatDate() and formatDecimal() utilities - Create 11 API Resource classes for all models - Update all 6 controllers to return wrapped responses via wrapResource() - Update frontend API client with unwrapResponse() helper - Update all 63+ backend tests to expect 'data' wrapper - Regenerate Scribe API documentation BREAKING CHANGE: All API responses now wrap data in 'data' key per architecture spec. Backend Tests: 70 passed, 5 failed (unrelated to data wrapper) Frontend Unit: 10 passed E2E Tests: 102 passed, 20 skipped API Docs: Generated successfully Refs: openspec/changes/api-resource-standard
21 lines
634 B
PHP
21 lines
634 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
class PtoResource extends BaseResource
|
|
{
|
|
public function toArray($request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'team_member_id' => $this->team_member_id,
|
|
'team_member' => $this->whenLoaded('teamMember', fn () => new TeamMemberResource($this->teamMember)),
|
|
'start_date' => $this->start_date?->toDateString(),
|
|
'end_date' => $this->end_date?->toDateString(),
|
|
'reason' => $this->reason,
|
|
'status' => $this->status,
|
|
'created_at' => $this->formatDate($this->created_at),
|
|
];
|
|
}
|
|
}
|