Overview
TheDenyResourceAction class handles the denial of pending resource requests. It updates the request status, logs the decision, and sends an email notification to the requester.
This action does not have any constructor dependencies. It can be instantiated directly without dependency injection.
Method Signature
Parameters
The pending resource request to deny (Eloquent model instance)
The admin user denying the request (used for audit logging)
Return Value
This action returnsvoid (no return value).
Side Effects
This action performs the following side effects:- Database Update: Updates the
PendingResourcerecord:- Sets
statusto'denied' - Sets
decided_atto the current timestamp
- Sets
- Audit Log: Creates a
ResourceLogentry with action typeDenied - Email Notification: Sends a
ResourceDecisionNotificationemail to the requester withapproved: false(if email is available)
Unlike
ApproveResourceAction, this action does not interact with the NetBird API or create any resources. The pending request remains in the database with a denied status.Example Usage
Email Notification
The action automatically sends an email notification to the requester if the pending resource has arequested_email value. The email uses the ResourceDecisionNotification mailable with approved: false.
Email notifications are sent asynchronously if your application is configured to use queues. If the email fails to send, the denial operation still succeeds.
Denied vs Deleted Requests
Error Scenarios
This action has minimal error scenarios since it only performs database updates and email sending:- Database errors: Will throw an exception if the database update fails
- Email errors: Will not prevent the denial from succeeding (emails are typically queued)
Source Reference
Implementation:/home/daytona/workspace/source/app/Actions/DenyResourceAction.php:19
Email notification helper: /home/daytona/workspace/source/app/Actions/DenyResourceAction.php:37