90 lines
2.3 KiB
PHP
90 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use CodeIgniter\Model;
|
|
|
|
class TicketMasterModel extends Model
|
|
{
|
|
protected $table = 'ticket_master';
|
|
protected $primaryKey = 'id';
|
|
protected $useAutoIncrement = true;
|
|
protected $returnType = 'array';
|
|
protected $useSoftDeletes = false;
|
|
protected $protectFields = true;
|
|
protected $allowedFields = [
|
|
'id',
|
|
'ticket_type_id',
|
|
'claim_status_id',
|
|
'acm_id',
|
|
'insurer_id',
|
|
'tpa_id',
|
|
'client_id',
|
|
'priority',
|
|
'policy_no',
|
|
'emp_code',
|
|
'tpa_no',
|
|
'emp_name',
|
|
'insured_name',
|
|
'relationship',
|
|
'emp_mobile',
|
|
'emp_mail',
|
|
'mode_of_intimation',
|
|
'claim_type',
|
|
'hospital_name',
|
|
'doa',
|
|
'dod',
|
|
'claim_amount',
|
|
'pod_no',
|
|
'created_by',
|
|
'updated_by',
|
|
'created_at',
|
|
'updated_at',
|
|
'date_of_join',
|
|
'date_of_incep',
|
|
'dob',
|
|
'date_of_accident',
|
|
'date_of_death',
|
|
'date_of_intimat',
|
|
'si_amt',
|
|
'is_active',
|
|
'claim_number',
|
|
'emp_id',
|
|
'insured_emp_id',
|
|
];
|
|
|
|
|
|
// 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;
|
|
}
|
|
}
|