Skip to content

Commit 229bcd1

Browse files
committed
docs ignoring helpers
1 parent 001039d commit 229bcd1

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

docs/helpers.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,38 @@ Behind the scenes, this will write a log to the requested `channel` to help you
8181
```
8282

8383
Keep in mind the log is written right after the process is dispatched, which means the log output does not represent the exact moment the action logic was executed. For situations where you are interacting with `deferred` or `queued` actions, you might see a difference between the log time and the actual execution time of the action logic, due to the way these actions are processed.
84+
85+
## Ignoring Helpers at Runtime
86+
87+
Now that you've read about helpers, you might be wondering if there's a way to ignore a specific helper to be applied to an action at runtime, am I right? The answer is: yes, you can determine an action as, for example, `deferred`, but ignore the `deferred` at runtime:
88+
89+
You don't need to do anything special in the action itself:
90+
91+
```php
92+
// app/Actions/CreateUser.php
93+
94+
execute('create user', function () {
95+
// ...
96+
})->deferred();
97+
```
98+
99+
Since you may still need to perform this action as deferred at any time, you need to interact with the `run` function to bypass the `deferred` helper at runtime:
100+
101+
```php {3}
102+
// ...
103+
104+
run('create user', deferred: false); // [!code focus]
105+
```
106+
107+
This way, the action will still be logged as a `deferred` action, but it will not be executed as a deferred action at the runtime you want to avoid. The same applies to the other helpers, such as `queued`, `rescued`, `logged`, and `then`.
108+
109+
Here is the complete list of options you can use to ignore helpers at runtime:
110+
111+
| Term | What |
112+
|-------------------|-----------------------------:|
113+
| `deferred: false` | To ignore `deferred` actions |
114+
| `queued: false` | To ignore `queued` actions |
115+
| `rescued: false` | To ignore `rescued` actions |
116+
| `logged: false` | To ignore `logged` actions |
117+
| `logged: false` | To ignore `logged` actions |
118+
| `then: false` | To ignore hooks |

0 commit comments

Comments
 (0)