diff --git a/src/Entries/Entry.php b/src/Entries/Entry.php index 54d6aaf6..a2da56c3 100644 --- a/src/Entries/Entry.php +++ b/src/Entries/Entry.php @@ -21,6 +21,10 @@ public static function fromModel(Model $model) $data[$key] = $model->$key; } + if ($model->order) { + $data['order'] = $model->order; + } + $entry = (new static) ->origin($model->origin_id) ->locale($model->site) diff --git a/src/Entries/EntryRepository.php b/src/Entries/EntryRepository.php index 4a3e00c6..85e25a7c 100644 --- a/src/Entries/EntryRepository.php +++ b/src/Entries/EntryRepository.php @@ -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'); diff --git a/src/Jobs/UpdateCollectionEntryOrder.php b/src/Jobs/UpdateCollectionEntryOrder.php index 8cfdebce..4e25ba24 100644 --- a/src/Jobs/UpdateCollectionEntryOrder.php +++ b/src/Jobs/UpdateCollectionEntryOrder.php @@ -12,16 +12,15 @@ class UpdateCollectionEntryOrder implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable; - public $entryId; - - public function __construct($entryId) - { - $this->entryId = $entryId; - } + public function __construct(public $entryId, public $entryOrder) {} public function handle() { if ($entry = Entry::find($this->entryId)) { + if ($this->entryOrder) { + $entry->set('order', $this->entryOrder); + } + $entry->save(); } }