|
27 | 27 | - [Views](#action-monitoring-views) |
28 | 28 | - [Reverse Proxy Config](#action-monitoring-reverse-proxy-config) |
29 | 29 | - [Action Monitoring Guest Mode](#action-monitoring-guest-mode) |
| 30 | + - [Action Monitoring Custom Conditions](#action-monitoring-custom-conditions) |
30 | 31 | - [Authentication Monitoring](#authentication-monitoring) |
31 | 32 | - [Views](#authentication-monitoring-views) |
32 | 33 | - [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. |
486 | 487 | ], |
487 | 488 | ``` |
488 | 489 |
|
| 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 | + |
489 | 518 | <a name="authentication-monitoring"></a> |
490 | 519 | ## Authentication Monitoring |
491 | 520 |
|
|
0 commit comments