46 lines
1.5 KiB
PHP
46 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use CodeIgniter\Model;
|
|
|
|
class ClientApiModel extends Model
|
|
{
|
|
protected $table = 'client_api';
|
|
protected $primaryKey = 'id';
|
|
protected $returnType = 'array';
|
|
protected $protectFields = true;
|
|
protected $allowedFields = [
|
|
'id','client_id','api_access','created_by','updated_by','created_at','updated_at',
|
|
'emp_method',"emp_url","emp_tkn_type","emp_token","emp_obj","claim_method",
|
|
"claim_url","claim_tkn_type","claim_token","claim_obj",'is_active',"client_token",
|
|
"pull_emp_token","pull_emp_obj","pull_claim_token","pull_claim_obj"
|
|
];
|
|
|
|
|
|
protected $beforeInsert = ["checkAndADDCreatedByValue"];
|
|
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
|
|
|
|
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;
|
|
}
|
|
}
|