39 lines
1.2 KiB
PHP
39 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class TicketStatusResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'allowed_target_statuses' => $this->whenLoaded(
|
|
'allowedTargetStatuses',
|
|
fn (): array => TicketStatusResource::collection($this->allowedTargetStatuses)->resolve(),
|
|
),
|
|
'board_column' => $this->whenLoaded(
|
|
'boardColumn',
|
|
fn (): ?array => $this->boardColumn === null
|
|
? null
|
|
: BoardColumnResource::make($this->boardColumn)->resolve(),
|
|
),
|
|
'board_column_id' => $this->board_column_id,
|
|
'name' => $this->name,
|
|
'position' => $this->position,
|
|
'project_id' => $this->project_id,
|
|
'slug' => $this->slug,
|
|
'created_at' => $this->created_at?->toISOString(),
|
|
'updated_at' => $this->updated_at?->toISOString(),
|
|
];
|
|
}
|
|
}
|