php-tenant/Events/Webhook/BoostActivatedEvent.php
Snider d0ad2737cb refactor: rename namespace from Core\Mod\Tenant to Core\Tenant
Simplifies the namespace hierarchy by removing the intermediate Mod
segment. Updates all 118 files including models, services, controllers,
middleware, tests, and composer.json autoload configuration.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 16:30:46 +00:00

58 lines
1.7 KiB
PHP

<?php
declare(strict_types=1);
namespace Core\Tenant\Events\Webhook;
use Core\Tenant\Contracts\EntitlementWebhookEvent;
use Core\Tenant\Models\Boost;
use Core\Tenant\Models\Feature;
use Core\Tenant\Models\Workspace;
/**
* Event fired when a boost is activated for a workspace.
*/
class BoostActivatedEvent implements EntitlementWebhookEvent
{
public function __construct(
protected Workspace $workspace,
protected Boost $boost,
protected ?Feature $feature = null
) {}
public static function name(): string
{
return 'boost_activated';
}
public static function nameLocalised(): string
{
return __('Boost Activated');
}
public function payload(): array
{
return [
'workspace_id' => $this->workspace->id,
'workspace_name' => $this->workspace->name,
'workspace_slug' => $this->workspace->slug,
'boost' => [
'id' => $this->boost->id,
'feature_code' => $this->boost->feature_code,
'feature_name' => $this->feature?->name ?? ucwords(str_replace(['.', '_', '-'], ' ', $this->boost->feature_code)),
'boost_type' => $this->boost->boost_type,
'limit_value' => $this->boost->limit_value,
'duration_type' => $this->boost->duration_type,
'starts_at' => $this->boost->starts_at?->toIso8601String(),
'expires_at' => $this->boost->expires_at?->toIso8601String(),
],
];
}
public function message(): string
{
$featureName = $this->feature?->name ?? $this->boost->feature_code;
return "Boost activated: {$featureName} for workspace {$this->workspace->name}";
}
}