Skip to content
This repository has been archived by the owner on Nov 9, 2024. It is now read-only.

Temporarily disable model hooks #2

Open
kerwanp opened this issue Oct 1, 2024 · 0 comments
Open

Temporarily disable model hooks #2

kerwanp opened this issue Oct 1, 2024 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@kerwanp
Copy link
Contributor

kerwanp commented Oct 1, 2024

Description

When creating, updating or deleting records, the Lucid model hooks will always run the documents update with no possibility to disable this behavior for specific actions.

Proposal

To match the Laravel Scout the Searchable model could provide a withoutSyncingToSearch static method that disable the model hooks for the passed callback.

Posts.withoutSyncingToSearch(async () => {
  await Post.create({ title: 'Hello world' })
})
@kerwanp kerwanp added the enhancement New feature or request label Oct 1, 2024
@kerwanp kerwanp added this to the v1 milestone Oct 1, 2024
@kerwanp kerwanp mentioned this issue Oct 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant