You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kwpayroll/app/Models/PayrollTypeModel.php

60 lines
1.8 KiB
PHP

<?php
namespace App\Models;
use CodeIgniter\Model;
class PayrollTypeModel extends Model
{
protected $table = 'pay_type';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = \App\Entities\PayrollType::class;
protected $useSoftDeletes = true;
protected $protectFields = true;
protected $allowedFields = ['paytype_code',
'paytype_name',
'is_monthly',
'is_semi_monthly',
'is_daily',
'is_hourly'];
protected bool $allowEmptyInserts = false;
// Dates
protected $useTimestamps = true;
protected $dateFormat = 'datetime';
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
protected $deletedField = 'deleted_at';
// Validation
protected $validationRules = [];
protected $validationMessages = [];
protected $skipValidation = false;
protected $cleanValidationRules = true;
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = ['assignCreatedBy'];
protected $afterInsert = [];
protected $beforeUpdate = ['assignUpdatedBy'];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
public function assignCreatedBy(array $data)
{
$data['data']['created_by'] = auth()->user()->employee_id;
return $data;
}
public function assignUpdatedBy(array $data)
{
$data['data']['updated_by'] = auth()->user()->employee_id;
return $data;
}
}