gurgentil / laravel-eloquent-sequencer

A package that allows you to create and manage sequences on Eloquent models.
MIT License
156 stars 13 forks source link

Sequence value `2` is out of bounds. #9

Closed phamquocbuu closed 4 years ago

phamquocbuu commented 4 years ago

Reproduce steps:

  1. Add 3 items, save. It's OK.
  2. Edit, remove 2 items, and add 1 new.
  3. Save -> It throws SequenceValueOutOfBoundsException.

My code:

// start with
$position = 1;
foreach ($orders as $index) {
    //...
    MyModel::updateOrCreate(
        [
         // ....
        ],
        [
            'position'           => $position++,
         // ....
        ]);

So what I have to do when I want to update position in this case?

phamquocbuu commented 4 years ago

Sorry, this is my mistake in code logic.