nhance/app/Models/RTOModel.php
venba-Inspriron-3558 7b1d98d86c FIX_Master screen
2025-10-14 15:03:51 +05:30

58 lines
1.5 KiB
PHP

<?php
namespace App\Models;
use CodeIgniter\Model;
class RTOModel extends Model
{
protected $table = 'rto_master';
protected $primaryKey = 'id';
protected $allowedFields = [
'id',
'rto_state',
'rto_code',
'rto_name',
'created_at',
'created_by',
'updated_at',
'updated_by',
'is_active',
];
// 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;
}}