在基类model添加
protected static function boot()
{
parent::boot();
static::creating(function ($data) {
// 新增操作后执行的逻辑
throw new \Exception('演示环境不允许更新');
logger('New post created: ' . $data);
});
static::updating(function ($data) {
throw new \Exception('演示环境不允许更新');
// 更新操作后执行的逻辑
logger('Post updated: ' . $data);
});
}