Skip to content

Commit

Permalink
Ensure entry order is set when using queue
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmitchell committed Nov 13, 2024
1 parent 01b187d commit f42a482
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Entries/EntryRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function updateOrders($collection, $ids = null)
->when($ids, fn ($query) => $query->whereIn('id', $ids))
->get(['id'])
->each(function ($entry) {
$dispatch = UpdateCollectionEntryOrder::dispatch($entry->id());
$dispatch = UpdateCollectionEntryOrder::dispatch($entry->id(), $entry->order());

$connection = config('statamic.eloquent-driver.collections.update_entry_order_connection', 'default');

Expand Down
9 changes: 5 additions & 4 deletions src/Jobs/UpdateCollectionEntryOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ class UpdateCollectionEntryOrder implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable;

public $entryId;

public function __construct($entryId)
public function __construct(public $entryId, public $order)
{
$this->entryId = $entryId;
}

public function handle()
{
if ($entry = Entry::find($this->entryId)) {
if ($this->order) {
$entry->order($this->order);
}

$entry->save();
}
}
Expand Down

0 comments on commit f42a482

Please sign in to comment.