php-tenant/Events/Webhook/BoostExpiredEvent.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 expires for a workspace.
*/
class BoostExpiredEvent implements EntitlementWebhookEvent
{
public function __construct(
protected Workspace $workspace,
protected Boost $boost,
protected ?Feature $feature = null
) {}
public static function name(): string
{
return 'boost_expired';
}
public static function nameLocalised(): string
{
return __('Boost Expired');
}
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,
'consumed_quantity' => $this->boost->consumed_quantity,
'duration_type' => $this->boost->duration_type,
'expired_at' => $this->boost->expires_at?->toIso8601String() ?? now()->toIso8601String(),
],
];
}
public function message(): string
{
$featureName = $this->feature?->name ?? $this->boost->feature_code;
return "Boost expired: {$featureName} for workspace {$this->workspace->name}";
}
}