action->object_type); $object = $actionObjectType->modelBuilder()->find($event->action->object_id); if (! $object) { return; } $userIds = match ($actionObjectType) { ActionObjectType::TASK => $object->assign > 0 ? [$object->assign] : [], ActionObjectType::REQUIREMENT=>$object->reviewed_by > 0 ? [$object->reviewed_by ] :[], default => [], }; if (! $userIds) { return; } $notification = Notification::query()->create([ 'object_type' => NotificationObjectType::ACTION->value, 'object_id' => $event->action->id, ]); foreach ($userIds as $userId) { NotificationRecord::query()->create([ 'notification_id' => $notification->id, 'user_id' => $userId, ]); } } 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]['browser'] ?? []); } }