mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-04-02 14:24:27 -04:00
Refactor: Add ALLOWED_SORT_COLUMNS constant and reuse in sanitization
- Add Item::ALLOWED_SORT_COLUMNS constant for allowed sort columns - Use constant in sanitizeSortColumnAttribute() instead of inline array - Enables reuse across the codebase for sort column validation
This commit is contained in:
@@ -79,9 +79,7 @@ class Items extends Secure_Controller
|
||||
return $default;
|
||||
}
|
||||
|
||||
$allowed_columns = ['items.item_id', 'item_number', 'name', 'category', 'company_name', 'cost_price', 'unit_price', 'quantity'];
|
||||
|
||||
if (in_array($field, $allowed_columns)) {
|
||||
if (in_array($field, Item::ALLOWED_SORT_COLUMNS, true)) {
|
||||
return $field;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ class Item extends Model
|
||||
'allow_alt_description',
|
||||
'is_serialized'
|
||||
];
|
||||
|
||||
public const ALLOWED_SORT_COLUMNS = ['items.item_id', 'item_number', 'name', 'category', 'company_name', 'cost_price', 'unit_price', 'quantity'];
|
||||
protected $table = 'items';
|
||||
protected $primaryKey = 'item_id';
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
Reference in New Issue
Block a user