Files
opensourcepos/app/Models/Rewards.php
Ollama 0a0a1e9aae fix: Remove type declarations from model properties and fix primaryKey bug
- Remove PHP type declarations from model property overrides to prevent fatal errors (CI4 Model declares without types)
- Fix wrong $primaryKey in Tax_jurisdiction (was 'cashup_id', now 'jurisdiction_id')
- Fix wrong $table in Customer_rewards (was 'customer_packages', now 'customers_packets')

Addresses CodeRabbit review comments
2026-04-16 19:37:52 +00:00

38 lines
945 B
PHP

<?php
namespace App\Models;
class Rewards extends BaseModel
{
protected $table = 'sales_reward_points';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $useSoftDeletes = false;
protected $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);
}
}