We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | $itemKeys = $this->model->query()->select($primaryKey)->get()->pluck($primaryKey); |
27 | 27 | |
28 | 28 | // filter the items that are not in the database and map the request |
29 | - $reorderItems = collect($request)->filter(function ($item) use ($itemKeys) { |
|
29 | + $reorderItems = collect($request)->filter(function($item) use ($itemKeys) { |
|
30 | 30 | return $item['item_id'] !== '' && $item['item_id'] !== null && $itemKeys->contains($item['item_id']); |
31 | - })->map(function ($item) use ($primaryKey) { |
|
31 | + })->map(function($item) use ($primaryKey) { |
|
32 | 32 | $item[$primaryKey] = (int) $item['item_id']; |
33 | 33 | $item['parent_id'] = empty($item['parent_id']) ? null : (int) $item['parent_id']; |
34 | 34 | $item['depth'] = empty($item['depth']) ? null : (int) $item['depth']; |
@@ -41,13 +41,13 @@ discard block |
||
41 | 41 | })->toArray(); |
42 | 42 | |
43 | 43 | // wrap the queries in a transaction to avoid partial updates |
44 | - DB::transaction(function () use ($reorderItems, $primaryKey, $itemKeys) { |
|
44 | + DB::transaction(function() use ($reorderItems, $primaryKey, $itemKeys) { |
|
45 | 45 | // create a string of ?,?,?,? to use as bind placeholders for item keys |
46 | 46 | $reorderItemsBindString = implode(',', array_fill(0, count($reorderItems), '?')); |
47 | 47 | |
48 | 48 | // each of this properties will be updated using a single query with a CASE statement |
49 | 49 | // this ensures that only 4 queries are run, no matter how many items are reordered |
50 | - foreach(['parent_id', 'depth', 'lft', 'rgt'] as $column) { |
|
50 | + foreach (['parent_id', 'depth', 'lft', 'rgt'] as $column) { |
|
51 | 51 | $query = ''; |
52 | 52 | $bindings = []; |
53 | 53 | $query .= "UPDATE {$this->model->getTable()} SET {$column} = CASE "; |