mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-30 19:26:22 -04:00
- 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
38 lines
945 B
PHP
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);
|
|
}
|
|
}
|