Skip to content

Commit e604b2d

Browse files
committed
UP
1 parent 4f43c33 commit e604b2d

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"require": {
2323
"php": "^8.1",
2424
"filament/filament": "^3.0",
25-
"spatie/eloquent-sortable": "^4.4",
2625
"spatie/laravel-package-tools": "^1.15.0"
2726
},
2827
"require-dev": {

src/Concerns/CrudOperationsTrait.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Relaticle\Flowforge\Concerns;
66

77
use Illuminate\Database\Eloquent\Model;
8+
use Illuminate\Database\Eloquent\SoftDeletingScope;
89

910
/**
1011
* Trait for handling CRUD operations in the Kanban adapter.
@@ -75,27 +76,26 @@ public function updateRecordsOrderAndColumn(string | int $columnId, array $recor
7576
{
7677
$orderField = $this->config->getOrderField();
7778
$columnField = $this->config->getColumnField();
78-
$success = true;
7979

80-
foreach ($recordIds as $index => $recordId) {
81-
$model = $this->getModelById($recordId);
80+
$startOrder = 1;
8281

83-
if ($model === null) {
84-
$success = false;
82+
foreach ($recordIds as $id) {
83+
$model = $this->getModelById($id);
84+
$primaryKeyColumn = $model->getQualifiedKeyName();
8585

86-
continue;
87-
}
86+
$attributes = [
87+
$columnField => $columnId,
88+
];
8889

8990
if ($orderField !== null) {
90-
$model->{$orderField} = $index + 1;
91+
$attributes[$orderField] = $startOrder++;
9192
}
92-
$model->{$columnField} = $columnId;
9393

94-
if (! $model->save()) {
95-
$success = false;
96-
}
94+
$model::withoutGlobalScope(SoftDeletingScope::class)
95+
->where($primaryKeyColumn, $id)
96+
->update($attributes);
9797
}
9898

99-
return $success;
99+
return true;
100100
}
101101
}

0 commit comments

Comments
 (0)