26 lines
712 B
PHP
26 lines
712 B
PHP
<?php
|
|
|
|
namespace App\Actions\ProjectBoard;
|
|
|
|
use App\Models\TicketStatus;
|
|
use Illuminate\Support\Arr;
|
|
|
|
class UpdateTicketStatusTransitions
|
|
{
|
|
/**
|
|
* @param array{allowed_ticket_status_ids?: array<int, int|string>|null} $validated
|
|
*/
|
|
public function handle(TicketStatus $ticketStatus, array $validated): TicketStatus
|
|
{
|
|
$allowedTicketStatusIds = collect(Arr::get($validated, 'allowed_ticket_status_ids', []))
|
|
->map(fn (int|string $ticketStatusId): int => (int) $ticketStatusId)
|
|
->unique()
|
|
->values()
|
|
->all();
|
|
|
|
$ticketStatus->allowedTargetStatuses()->sync($allowedTicketStatusIds);
|
|
|
|
return $ticketStatus->fresh();
|
|
}
|
|
}
|