Model ticket link counterparts explicitly
This commit is contained in:
@@ -12,16 +12,18 @@ class StoreTicketLinkType
|
||||
use ReordersProjectMetadata;
|
||||
|
||||
/**
|
||||
* @param array{name: string, position?: int|null} $validated
|
||||
* @param array{name: string, counterpart_name: string, position?: int|null} $validated
|
||||
*/
|
||||
public function handle(Project $project, array $validated): TicketLinkType
|
||||
{
|
||||
$name = Arr::get($validated, 'name');
|
||||
$counterpartName = Arr::get($validated, 'counterpart_name');
|
||||
$position = Arr::get($validated, 'position');
|
||||
|
||||
return DB::transaction(function () use ($project, $position, $name): TicketLinkType {
|
||||
return DB::transaction(function () use ($project, $position, $name, $counterpartName): TicketLinkType {
|
||||
$ticketLinkType = $project->ticketLinkTypes()->create([
|
||||
'label' => $name,
|
||||
'counterpart_label' => $counterpartName,
|
||||
'position' => $project->ticketLinkTypes()->count() + 1,
|
||||
]);
|
||||
|
||||
|
||||
@@ -12,16 +12,18 @@ class UpdateTicketLinkType
|
||||
use ReordersProjectMetadata;
|
||||
|
||||
/**
|
||||
* @param array{name: string, position: int} $validated
|
||||
* @param array{name: string, counterpart_name: string, position: int} $validated
|
||||
*/
|
||||
public function handle(Project $project, TicketLinkType $ticketLinkType, array $validated): TicketLinkType
|
||||
{
|
||||
$name = Arr::get($validated, 'name');
|
||||
$counterpartName = Arr::get($validated, 'counterpart_name');
|
||||
$position = Arr::get($validated, 'position');
|
||||
|
||||
DB::transaction(function () use ($project, $name, $position, $ticketLinkType): void {
|
||||
DB::transaction(function () use ($project, $name, $counterpartName, $position, $ticketLinkType): void {
|
||||
$ticketLinkType->update([
|
||||
'label' => $name,
|
||||
'counterpart_label' => $counterpartName,
|
||||
]);
|
||||
|
||||
$this->reorderModels(
|
||||
|
||||
Reference in New Issue
Block a user