如何触发更新数据库中记录后触发的事件? [OctoberCMS]

问题描述 投票:0回答:1

我一直试图触发一个事件,该事件告诉我记录中的特定信息是否已更改,但是我无法执行(没有给出任何错误,但未记录我期望的信息)

我已在启动功能的Plugin.php文件中添加了此选项

        $comment =  new ExpertsComment;
        $comment->bindEvent('model.afterUpdate', function () use (\October\Rain\Database\Model $model) {
            if ($model->is_approved !== $model->original['is_approved']) {
              Log::info("Event Fired!");
         }
        });

从这里https://octobercms.com/docs/api/model/afterupdate使用此

octobercms octobercms-backend
1个回答
1
投票

专家评论您的课程吗?如果是这样,您可以在plugins/foo/bar/models/ExpertsComment.php中将事件直接添加到模型中。不要忘记在use Log;中添加日志外观ExpertsComment.phpHere are documents for model event basic usage.

© www.soinside.com 2019 - 2024. All rights reserved.