Skip to content

Commit 32fde43

Browse files
committed
add Action Monitoring Custom Conditions to readme
1 parent 974037e commit 32fde43

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
- [Views](#action-monitoring-views)
2828
- [Reverse Proxy Config](#action-monitoring-reverse-proxy-config)
2929
- [Action Monitoring Guest Mode](#action-monitoring-guest-mode)
30+
- [Action Monitoring Custom Conditions](#action-monitoring-custom-conditions)
3031
- [Authentication Monitoring](#authentication-monitoring)
3132
- [Views](#authentication-monitoring-views)
3233
- [How to use in big projects](#how-to-use-in-big-projects)
@@ -486,6 +487,34 @@ When set to `false`, only authenticated user visits will be recorded.
486487
],
487488
```
488489

490+
<a name="action-monitoring-custom-conditions"></a>
491+
### Action Monitoring Custom Conditions
492+
493+
The `Laravel User Monitoring` package lets you define custom conditions for action monitoring (create, update, delete events on models).
494+
Conditions give you control over when model actions should be logged.
495+
496+
#### 🔧 How It Works
497+
498+
- Conditions are checked before an action is stored.
499+
- If any condition returns false, the action will be skipped.
500+
- You can define conditions as closures or class-based rules.
501+
502+
```php
503+
'action_monitoring' => [
504+
'conditions' => [
505+
// Class-based condition (must implement MonitoringCondition interface)
506+
\App\Monitoring\YourCustomCondition::class,
507+
508+
// Closure-based condition (receives the Request and authenticated User)
509+
function (Illuminate\Http\Request $request) {
510+
$user = $request->user();
511+
512+
return $user && $user->isAdmin();
513+
},
514+
],
515+
],
516+
```
517+
489518
<a name="authentication-monitoring"></a>
490519
## Authentication Monitoring
491520

0 commit comments

Comments
 (0)