Skip to content

Commit

Permalink
Update Sortable.php (#239)
Browse files Browse the repository at this point in the history
Eliminate hard-coded 'id' as primary database key. Check for $primaryKey defined in the model, default to 'id'.
  • Loading branch information
sammyschnei authored and daftspunk committed Sep 22, 2016
1 parent dc09736 commit f1ebde5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Database/Traits/Sortable.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function setSortableOrder($itemIds, $itemOrders = null)

foreach ($itemIds as $index => $id) {
$order = $itemOrders[$index];
$this->newQuery()->where('id', $id)->update([$this->getSortOrderColumn() => $order]);
$this->newQuery()->where($this->getKeyName(), $id)->update([$this->getSortOrderColumn() => $order]);
}
}

Expand All @@ -73,4 +73,4 @@ public function getSortOrderColumn()
return defined('static::SORT_ORDER') ? static::SORT_ORDER : 'sort_order';
}

}
}

0 comments on commit f1ebde5

Please sign in to comment.