Skip to content

Commit

Permalink
Merge pull request #5660 from Laravel-Backpack/use-connection-name-in…
Browse files Browse the repository at this point in the history
…-reorder-functions

use connection name in db reorder functions
  • Loading branch information
pxpm authored Sep 16, 2024
2 parents 9050d81 + 00a95b2 commit aacabbc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/app/Library/CrudPanel/Traits/Reorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function updateTreeOrder($request)
});

// wrap the queries in a transaction to avoid partial updates
DB::transaction(function () use ($reorderItems, $primaryKey, $itemKeys) {
DB::connection($this->model->getConnectionName())->transaction(function () use ($reorderItems, $primaryKey, $itemKeys) {
// create a string of ?,?,?,? to use as bind placeholders for item keys
$reorderItemsBindString = implode(',', array_fill(0, count($reorderItems), '?'));

Expand All @@ -68,7 +68,7 @@ public function updateTreeOrder($request)
// add the where clause to the query to help match the items
$query .= "ELSE {$column} END WHERE {$primaryKey} IN ({$reorderItemsBindString})";

DB::statement($query, $bindings);
DB::connection($this->model->getConnectionName())->statement($query, $bindings);
}
});

Expand Down

0 comments on commit aacabbc

Please sign in to comment.