Skip to content

Commit 9fe49ad

Browse files
committed
Added onStageSorted changed to leads board
1 parent cda7ec3 commit 9fe49ad

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/Http/Livewire/LiveLeadBoard.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,32 @@ public function stages(): Collection
2323
}
2424
}
2525

26+
public function onStageSorted($orderedIds)
27+
{
28+
foreach ($orderedIds as $orderNumber => $leadId) {
29+
Lead::find($leadId)->update([
30+
'pipeline_stage_order' => $orderNumber + 1,
31+
]);
32+
}
33+
}
34+
2635
public function onStageChanged($recordId, $stageId, $fromOrderedIds, $toOrderedIds)
2736
{
2837
Lead::find($recordId)->update([
2938
'pipeline_stage_id' => $stageId
3039
]);
40+
41+
foreach ($fromOrderedIds as $orderNumber => $leadId) {
42+
Lead::find($leadId)->update([
43+
'pipeline_stage_order' => $orderNumber + 1,
44+
]);
45+
}
46+
47+
foreach ($toOrderedIds as $orderNumber => $leadId) {
48+
Lead::find($leadId)->update([
49+
'pipeline_stage_order' => $orderNumber + 1,
50+
]);
51+
}
3152
}
3253

3354
public function records(): Collection

0 commit comments

Comments
 (0)