27 lines
744 B
PHP
27 lines
744 B
PHP
<?php
|
|
|
|
namespace App\Actions\Projects;
|
|
|
|
use App\Http\Resources\TicketStatusResource;
|
|
use App\Models\Ticket;
|
|
|
|
class BuildProjectTicketStatusTargetsPayload
|
|
{
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function handle(Ticket $ticket): array
|
|
{
|
|
$ticket->loadMissing('ticketStatus.allowedTargetStatuses.boardColumn');
|
|
|
|
return [
|
|
'current_status' => $ticket->ticketStatus === null
|
|
? null
|
|
: TicketStatusResource::make($ticket->ticketStatus->loadMissing('boardColumn'))->resolve(),
|
|
'target_statuses' => TicketStatusResource::collection(
|
|
$ticket->ticketStatus?->allowedTargetStatuses ?? collect(),
|
|
)->resolve(),
|
|
];
|
|
}
|
|
}
|