Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 数据批量操作,不能触发hyperf模型事件 restoring 和 restored 钩子 #36

Closed
wants to merge 1 commit into from

Conversation

andphp
Copy link

@andphp andphp commented Aug 18, 2024

批量恢复数据不会走SoftDeletes::restore方法

    /**
     * 单个或批量从回收站恢复数据.
     */
    public function recovery(array $ids): bool
    {
        $this->model::withTrashed()->whereIn((new $this->model())->getKeyName(), $ids)->restore();
        return true;
    }

需要使用循环单个处理

    public function recovery(array $ids): bool
    {
        foreach ($ids as $id) {
            $model = $this->model::withTrashed()->find($id);
            $model && $model->restore();
        }
        return true;
    }```

Copy link

Hi, this is a READ-ONLY repository, please submit your PR on the https://github.com/mineadmin/components repository.

This Pull Request will close automatically.

Thanks!

@github-actions github-actions bot closed this Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant