clqms-be/app/Models/Rule/RuleActionModel.php
mahdahar 88be3f3809 feat: add rules engine API and order-created hook
- Add /api/rules CRUD, nested actions, and expr validation

- Add rules migration, models, and RuleEngine/Expression services

- Run ORDER_CREATED rules after order create (non-blocking) and refresh tests

- Update OpenAPI tags/schemas/paths and bundled docs
2026-03-12 06:34:56 +07:00

41 lines
917 B
PHP

<?php
namespace App\Models\Rule;
use App\Models\BaseModel;
class RuleActionModel extends BaseModel
{
protected $table = 'ruleaction';
protected $primaryKey = 'RuleActionID';
protected $allowedFields = [
'RuleID',
'Seq',
'ActionType',
'ActionParams',
'CreateDate',
'EndDate',
];
protected $useTimestamps = true;
protected $createdField = 'CreateDate';
protected $updatedField = '';
protected $useSoftDeletes = true;
protected $deletedField = 'EndDate';
public function getActiveByRuleIDs(array $ruleIDs): array
{
if (empty($ruleIDs)) {
return [];
}
return $this->whereIn('RuleID', $ruleIDs)
->where('EndDate IS NULL')
->orderBy('RuleID', 'ASC')
->orderBy('Seq', 'ASC')
->orderBy('RuleActionID', 'ASC')
->findAll();
}
}