php-tenant/Events/Webhook/LimitReachedEvent.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

52 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace Core\Tenant\Events\Webhook;
use Core\Tenant\Contracts\EntitlementWebhookEvent;
use Core\Tenant\Models\Feature;
use Core\Tenant\Models\Workspace;
/**
* Event fired when workspace usage reaches 100% of the limit.
*/
class LimitReachedEvent implements EntitlementWebhookEvent
{
public function __construct(
protected Workspace $workspace,
protected Feature $feature,
protected int $used,
protected int $limit
) {}
public static function name(): string
{
return 'limit_reached';
}
public static function nameLocalised(): string
{
return __('Limit Reached');
}
public function payload(): array
{
return [
'workspace_id' => $this->workspace->id,
'workspace_name' => $this->workspace->name,
'workspace_slug' => $this->workspace->slug,
'feature_code' => $this->feature->code,
'feature_name' => $this->feature->name,
'used' => $this->used,
'limit' => $this->limit,
'percentage' => 100,
'remaining' => 0,
];
}
public function message(): string
{
return "Limit reached: {$this->feature->name} at 100% ({$this->used}/{$this->limit}) for workspace {$this->workspace->name}";
}
}