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:
Ollama
2026-04-15 15:29:43 +00:00
parent baf135dd42
commit e7daa7a9db

View File

@@ -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