70 lines
1.8 KiB
PHP
Executable File
70 lines
1.8 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use CodeIgniter\Model;
|
|
|
|
class PolicyPremium1Model extends Model
|
|
{
|
|
protected $table = 'policy_premium_1';
|
|
protected $primaryKey = 'id';
|
|
protected $allowedFields = [
|
|
|
|
'id',
|
|
'client_id',
|
|
'client_policy_id',
|
|
'policy_grid_id',
|
|
'si',
|
|
'si_or_bp',
|
|
'basic_multiplier',
|
|
'premium_multiplier',
|
|
'basic_pay',
|
|
'premium',
|
|
'multiplier',
|
|
"created_by",
|
|
"updated_by",
|
|
'is_active',
|
|
'grade',
|
|
'premium_type',
|
|
'rack_rate_name',
|
|
'unit',
|
|
'additional_relationship',
|
|
|
|
];
|
|
|
|
// Callbacks
|
|
protected $allowCallbacks = true;
|
|
protected $beforeInsert = ["checkAndADDCreatedByValue"];
|
|
protected $afterInsert = [];
|
|
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
|
|
protected $afterUpdate = [];
|
|
protected $beforeFind = [];
|
|
protected $afterFind = [];
|
|
protected $beforeDelete = [];
|
|
protected $afterDelete = [];
|
|
|
|
protected function checkAndADDCreatedByValue(array $data)
|
|
{
|
|
// Check if 'updated_by' value is null or empty
|
|
if (empty($data['data']['created_by'])) {
|
|
// Set 'updated_by' value to the current session user ID
|
|
$data['data']['created_by'] = get_session_userid();
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
|
|
protected function checkAndUpdateUpdatedByValue(array $data)
|
|
{
|
|
// Check if 'updated_by' value is null or empty
|
|
if (empty($data['data']['updated_by'])) {
|
|
// Set 'updated_by' value to the current session user ID
|
|
$data['data']['updated_by'] = get_session_userid();
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
|
|
|
|
}
|