Files
opensourcepos/app/Models/Rewards.php
Ollama e17e85bc4c refactor: Add getters for protected model properties
- Create BaseModel with getters for $table, $primaryKey, $allowedFields
- All models now extend BaseModel instead of CodeIgniter\Model
- Add type declarations to protected properties

Closes #4489
2026-04-15 12:40:24 +00:00

38 lines
975 B
PHP

<?php
namespace App\Models;
class Rewards extends BaseModel
{
protected string $table = 'sales_reward_points';
protected string $primaryKey = 'id';
protected bool $useAutoIncrement = true;
protected bool $useSoftDeletes = false;
protected array $allowedFields = [
'sale_id',
'earned',
'used'
];
/**
* Inserts or updates a rewards
*/
public function save_value(array &$rewards_data, bool $rewards_id = false): bool
{
$builder = $this->db->table('sales_reward_points');
if (!$rewards_id || !$this->exists($rewards_id)) { // TODO: looks like we are missing the exists function in this class
if ($builder->insert($rewards_data)) {
$rewards_data['id'] = $this->db->insertID();
return true;
}
return false;
}
$builder->where('id', $rewards_id);
return $builder->update($rewards_data);
}
}