123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace App\Listeners;
- use App\Events\ObjectActionCreate;
- use App\Models\Enums\ActionObjectType;
- use App\Models\Enums\ObjectAction;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Queue\InteractsWithQueue;
- class SendActionEmailNotification implements ShouldQueue
- {
- /**
- * Create the event listener.
- */
- public function __construct()
- {
- //
- }
- /**
- * Handle the event.
- */
- public function handle(ObjectActionCreate $event): void
- {
- }
- public function shouldQueue(ObjectActionCreate $event): bool
- {
- $actionObjectType = ActionObjectType::tryFrom($event->action->object_type);
- $objectAction = ObjectAction::tryFrom($event->action->action);
- if (! $actionObjectType || !$objectAction) {
- return false;
- }
- return in_array($objectAction->value, $event->notificationSetting[$actionObjectType->value]['email'] ?? []);
- }
- }
|