clqms-be/app/Models/Rule/RuleActionModel.php

50 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace App\Models\Rule;
use App\Models\BaseModel;
/**
* RuleAction Model
*
* Actions that can be executed when a rule matches.
*/
class RuleActionModel extends BaseModel
{
protected $table = 'ruleaction';
protected $primaryKey = 'RuleActionID';
protected $allowedFields = [
'RuleID',
'ActionType',
'ActionParams',
'CreateDate',
'EndDate',
];
protected $useTimestamps = true;
protected $createdField = 'CreateDate';
protected $updatedField = '';
protected $useSoftDeletes = true;
protected $deletedField = 'EndDate';
/**
* Get active actions by rule IDs
*
* @param array $ruleIDs Array of RuleID values
* @return array Array of actions
*/
public function getActiveByRuleIDs(array $ruleIDs): array
{
if (empty($ruleIDs)) {
return [];
}
return $this->whereIn('RuleID', $ruleIDs)
->where('EndDate IS NULL')
->orderBy('RuleID', 'ASC')
->orderBy('RuleActionID', 'ASC')
->findAll();
}
}