mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-07-25 22:27:05 -04:00
fix: Remove primary key from update payload
- Unset item_id from data array before update - Cleaner approach to avoid including PK in update payload Address CodeRabbit review feedback
This commit is contained in:
@@ -450,9 +450,13 @@ class Item extends Model
|
||||
|
||||
// If id > 0 and record exists, update it
|
||||
if ($id > 0 && $this->exists($id, true)) {
|
||||
// Remove primary key from data array for update
|
||||
$updateData = $data;
|
||||
unset($updateData[$primaryKey]);
|
||||
|
||||
$builder = $this->db->table('items');
|
||||
$builder->where($primaryKey, $id);
|
||||
return $builder->update($data);
|
||||
return $builder->update($updateData);
|
||||
}
|
||||
|
||||
// Insert new record
|
||||
|
||||
Reference in New Issue
Block a user