You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/helpers.md
+35Lines changed: 35 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -81,3 +81,38 @@ Behind the scenes, this will write a log to the requested `channel` to help you
81
81
```
82
82
83
83
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:
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:
0 commit comments