|
@@ -16,6 +16,7 @@ private function baseQuery()
|
|
|
public function getAll(): Collection
|
|
public function getAll(): Collection
|
|
|
{
|
|
{
|
|
|
return $this->baseQuery()
|
|
return $this->baseQuery()
|
|
|
|
|
+ ->orderBy('order', 'asc')
|
|
|
->orderBy('created_at', 'desc')
|
|
->orderBy('created_at', 'desc')
|
|
|
->get();
|
|
->get();
|
|
|
}
|
|
}
|
|
@@ -24,10 +25,25 @@ public function getAllForUnit(int $unitId): Collection
|
|
|
{
|
|
{
|
|
|
return $this->baseQuery()
|
|
return $this->baseQuery()
|
|
|
->visibleToUnit($unitId)
|
|
->visibleToUnit($unitId)
|
|
|
|
|
+ ->orderBy('order', 'asc')
|
|
|
->orderBy('created_at', 'desc')
|
|
->orderBy('created_at', 'desc')
|
|
|
->get();
|
|
->get();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Bulk-update phase + order for a set of cards (drag-and-drop persistence).
|
|
|
|
|
+ * Expects: [['id' => int, 'phase' => string, 'order' => int], ...]
|
|
|
|
|
+ */
|
|
|
|
|
+ public function reorder(array $items): void
|
|
|
|
|
+ {
|
|
|
|
|
+ foreach ($items as $item) {
|
|
|
|
|
+ Kanban::where('id', $item['id'])->update([
|
|
|
|
|
+ 'phase' => $item['phase'],
|
|
|
|
|
+ 'order' => $item['order'],
|
|
|
|
|
+ ]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public function findById(int $id): ?Kanban
|
|
public function findById(int $id): ?Kanban
|
|
|
{
|
|
{
|
|
|
return $this->baseQuery()->find($id);
|
|
return $this->baseQuery()->find($id);
|